Search code examples
titaniumappceleratorappcelerator-titanium

Appcelerator Titanium: How do I change SearchView colors on Android? (hintText and cross icon)


I have a SearchView which is dark and its hinttext and its cross icon are black, so I want to set the color of these two things to white.

I am using a custom theme for Android but it does nothing to the SearchView. This is how my custom theme xml file looks like:

<resources>
 <style name="Theme.MyApp" parent="@style/Theme.AppCompat.Light.DarkActionBar">

    <item name="android:spinnerItemStyle">@style/MySpinnerItem</item>

    <item name="android:actionBarStyle">@style/SearchViewTheme</item>

 </style>

 <style name="SearchViewTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="android:textColorPrimary">#FFFFFF</item>
    <item name="android:textColorSecondary">#FFFFFF</item>
    <item name="android:textColorHint">#CCCCCC</item>
 </style>

 <style name="MySpinnerItem" parent="@android:style/Widget.TextView.SpinnerItem">
    <item name="android:paddingTop">10dp</item>
    <item name="android:paddingBottom">10dp</item>
    <item name="android:paddingLeft">10dp</item>
    <item name="android:textSize">14dp</item>
 </style>

</resources>

Solution

  • I found a solution. If anyone wants to know what I did:

    I just deleted this line:

    <item name="android:actionBarStyle">@style/SearchViewTheme</item>
    

    And then, I added this to the .tss file where the SearchView is:

    "Window[platform=android]" : {
        theme : "SearchViewTheme"
    }