androidmaterial-designsearchview

Android: How can I Change the SearchView hint text color?


following is my code snippet for reference

<android.support.v7.widget.SearchView
            android:id="@+id/search"
            style="@style/SearchViewStyle"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textColorHint="@android:color/black"
            android:clickable="true"
            android:focusable="true"/>

by using this android:textColorHint="@android:color/black" things not work. any help appreciated!


Solution

  • yes i solve my problem by using fallowing changes in code

     search = (SearchView) rootView.findViewById(R.id.search);
        // search.setQueryHint("search");
        searchEditText = (EditText)search.findViewById(android.support.v7.appcompat.R.id.search_src_text);
        searchEditText.setTextColor(getResources().getColor(R.color.colorPrimary));
        searchEditText.setHintTextColor(getResources().getColor(R.color.colorPrimary));
        searchEditText.setHint("search here for quick access");
    

    I comment search.setQueryHint("search"); method. and I access EditText of the searchview, and call the searchEditText.setHint("search here for quick access");