The Android searchview has default queryhint textcolor and text color . How we can change the text color of edittext in Android Searchview using AndroidX
The Android searchview has default queryhint textcolor and text color . How we can change the text color of edittext in Android Searchview using AndroidX
The searchView below is the reference variable of Searchview you are using .
JAVA:
EditText editText = searchView.findViewById(androidx.appcompat.R.id.search_src_text);
editText.setTextColor(Color.WHITE);
editText.setHintTextColor(Color.GRAY);
KOTLIN
val editText = searchView.findViewById(androidx.appcompat.R.id.search_src_text)
editText.setTextColor(Color.WHITE)
You can do it programmatically if you wish and which is a pretty good trick, well I am telling you how to do it in XML:
You will find 3 colors defined there, Add colors there let suppose blue and orange colors like this
<color name="colorblue">#FF0A7FE4</color>
<color name="colororange">#F76707</color>
Now got to the XML where you have that search box EditText
In that editText view add attributes :
android:textColorHint="@color/colorblue"
android:textColor="@color/colororange"
there you will find the hint color will be now changed to blue and the text color will now be orange.