Search code examples
androidxamarinstylessearchview

Android SearchView Text color


I am trying to make the text the user types of the search view white. "android:searchViewTextField" give an error. I can't find the right name for a global style:

<style name="AppTheme" parent="@style/_AppTheme"/>

<style name="_AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
  <item name="android:searchViewTextField">@color/white_color</item>
 </style>

Is there a global style which will only affect the text of the Searchview and not all text boxes?


Solution

  • Define the theme "SearchTextViewTheme"

    <style name="SearchTextViewTheme" parent="android:Theme.Holo.Light.DarkActionBar">
        <item name="android:textColor">@color/white_color</item>
    </style>
    

    Then inside the TextView

    <TextView
        style="@style/SearchTextViewTheme"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>
    

    In fact applying theme must be explicitly defined in the layout XML. Therefore you do not have to worry about the theme affecting other text boxes