How can I change the action bar search view hint text colour?
This question explains how to get the EditText when using ABS: Android ActionBar Customize Search View
Is there a android.R.id I could use to get a reference to the EditText so I could change the hint colour? Or is there some other way to change the colour?
this worked for me, hope it helps
also see this
Try this code. It is very easy.
searchEditText.setHintTextColor(getResources().getColor(R.color.white));
Here's specifically how you apply the style as hinted at above. The right answer is to overload the action bar widget style with your own custom style. For holo light with dark action bar, put this in your own styles file such as
res/values/styles_mytheme.xml
:Make sure your application is using theme custom theme as described in enter link description here
A
SearchView
object extends fromLinearLayout
, so it holds other views. The trick is to find the view holding the hint text and change the colour programmatically. By traversing the view hierarchy, you can find the widget containing the hint text:This method works with any theme. Also, you can change the look of other widgets in the
SearchView
hierarchy, such as theEditText
holding the search query.With the most recent appcompat library (or if you're targeting 5.0+), this is possible to do purely in XML using a
ThemeOverlay
:And then in your layout file:
If you also want it to apply to activities that are using an
ActionBar
instead of aToolbar
, you can add this to theActivity
's theme: