Set SearchView clear button color

后端 未结 5 1205
粉色の甜心
粉色の甜心 2021-01-11 11:17

I am creating a searchview in the toolbar using onCreateOptionsMenu, but can\'t get the clear X button to initially be white. It becomes white when

5条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-11 11:57

    You can also set it from XML. I'm using the support library 24.2.1 and an activity with a theme whose parent is "Theme.AppCompat.Light" and an android.support.v7.widget.SearchView in the ActionBar.

    You can set an actionBarWidgetTheme in your activity theme like this:

    
    

    And then define MyActionBarWidgetTheme and set the colours you want there:

    
    
    • android:textColorSecondary applies to the close icon

    • android:textColorPrimary applies to the text you enter

    • colorControlActivated applies to the cursor

    • android:textColorHint applies to the hint text

提交回复
热议问题