How to change the course color of my Searchview

Asked

Viewed 172 times

0

For now it is white and I need to put it in black color, I found several tutorials, but I did not find one that works, how do I do it?

Code:

    searchViewPesquisa = (SearchView) findViewById(R.id.searchViewPesquisa);

    EditText searchEditText = (EditText) searchViewPesquisa.findViewById(android.support.v7.appcompat.R.id.search_src_text);
    searchEditText.setTextColor(getResources().getColor(R.color.textColorThird));
    searchEditText.setHintTextColor(getResources().getColor(R.color.textColorThird));

    searchViewPesquisa.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            searchViewPesquisa.setIconified(false);
        }
    });

xml:

<android.support.v7.widget.CardView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="15dp"
    app:cardBackgroundColor="@color/colorBackgroud">

    <android.support.v7.widget.SearchView
        android:id="@+id/searchViewPesquisa"
        style="@style/SearchViewStyle"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
</android.support.v7.widget.CardView>

style:

<style name="SearchViewStyle" parent="Widget.AppCompat.SearchView">

    <item name="searchHintIcon">@drawable/ic_search_black_24dp</item>
    <item name="closeIcon">@drawable/ic_close</item>
    <item name="searchIcon">@drawable/ic_search_black_24dp</item>

</style>

1 answer

-1

I decided to create a "cursor_color300.xml" cursor in the drawable folder like this:

inserir a descrição da imagem aqui

After I set it in the property textCursorDrawable in my main theme so:

inserir a descrição da imagem aqui

If everything is correct it will work perfectly.

  • 1

    Do not use photos to manifest code. The view can become a proleme depending on the device used by the reader. It is also not possible to use [CTRL+C] [CTRL+V] in code image. Ideally, text formatted with Markdown.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.