Search code examples
androidkotlinsearchviewandroidx

How to change the textcolor or queryhint textcolor of an Android SearchView in 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


Solution

  • 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)