NativeScript icon indicating copy to clipboard operation
NativeScript copied to clipboard

SearchBar: ability to change color of clear button ("X")

Open manigorsh opened this issue 8 years ago • 6 comments

Please, provide the details below:

Did you verify this is a real problem by searching Stack Overflow and the other open issues in this repo?

Yes

Tell us about the problem

I can't change color of clear button on SearchBar.

Which platform(s) does your issue occur on?

Both


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

manigorsh avatar Dec 20 '17 13:12 manigorsh

Hi @manigorsh, Thank you for contacting us. At this time there is no functionality, which provides a way to change the style of the SearchBar clear button. Regarding that, I will log this issue as a new feature and we will check if there is a simple way to provide a support for similar functionality. In the meantime as a temporary solution, you could review this thread here, where is suggested to create custom SearchBar, where you could provide the needed styling.

Something else, you could also review this thread in StackOverflow and to try changing the button style via the android theme.

tsonevn avatar Dec 21 '17 06:12 tsonevn

Hi @tsonevn

What would be the parent of SearchBar in NativeScript. Here's my styles.xml under values-v21 and it has not changed the icon. I've also tried parent=

  • android:Widget.Material.SearchView
  • android:Widget.AppCompat.SearchView
  • Widget.AppCompat.SearchView

`

<!-- Application theme -->
<style name="AppTheme" parent="AppThemeBase">
    <item name="android:datePickerStyle">@style/SpinnerDatePicker</item>
    <item name="android:timePickerStyle">@style/SpinnerTimePicker</item>
    <item name="android:searchViewStyle">@style/SearchViewStyle</item>
</style>

<!-- Default style for DatePicker - in spinner mode -->
<style name="SpinnerDatePicker" parent="android:Widget.Material.Light.DatePicker">
    <item name="android:datePickerMode">spinner</item>
</style>

<!-- Default style for TimePicker - in spinner mode -->
<style name="SpinnerTimePicker" parent="android:Widget.Material.Light.TimePicker">
    <item name="android:timePickerMode">spinner</item>
</style>

<style name="NativeScriptToolbarStyle" parent="NativeScriptToolbarStyleBase">
    <item name="android:elevation">4dp</item>
</style>

<style name="SearchViewStyle" parent="android:Widget.Material.SearchView">
    <item name="android:closeIcon">@android:drawable/ic_menu_search</item>
</style>
`

noumaans avatar Feb 01 '18 00:02 noumaans

@noumaans behind SearchBar for Android stands android.support.v7.widget.SearchView

Android source code here

NickIliev avatar Mar 23 '18 12:03 NickIliev

This might be a good opportunity to contribute to the NativeScript framework (assuming you want to get your hand dirty with some android-specific styling of course).

The way I see it. Anyone willing to create a PR with such functionality should:

vakrilov avatar Sep 19 '18 14:09 vakrilov

I can also add that the color of the magnifier button in both platforms can't be changed.

bundyo avatar Feb 06 '19 16:02 bundyo

Hey is this issue resolved or still open? If open may I submit a PR to solve this? I would like to get assigned to solve this issue/

sourabratabose avatar Mar 16 '25 14:03 sourabratabose

Hey is this issue resolved? I would like to contribute. ¿Could you assign it to me?

Alonso2002-jpg avatar Sep 04 '25 22:09 Alonso2002-jpg

Hi @Alonso2002-jpg and @sourabratabose thanks for contribution mention - no need for assignment, feel free to try a PR and if it works, we can include it in the next major release (v9), currently underway.

NathanWalker avatar Sep 05 '25 02:09 NathanWalker

hi @tsonevn @NickIliev I want to fix this issue? can I be assigned for it?

muhammadali-se avatar Sep 23 '25 06:09 muhammadali-se