如何更改SearchView textcolor? [英] How to change SearchView textcolor?

查看:58
本文介绍了如何更改SearchView textcolor?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 SearchView 位于LinearLayout/RelativeLayout中,而不是操作中酒吧.

My SearchView is located in a LinearLayout / RelativeLayout rather than the action bar.

其默认文本颜色为白色,如何更改?

Its default text color is white, how to change it?

推荐答案

深入研究appcompat SearchView的源代码,我发现它使用了 AppCompatAutoCompleteTextView ,默认情况下,该代码使用 autoCompleteTextView 样式.

Digging into the source code of the appcompat SearchView I found that it uses an AppCompatAutoCompleteTextView which by default uses the autoCompleteTextView style.

创建不同的自动填充样式并将其设置为应用主题可以为我解决问题.

Creating a different autocomplete style and setting it in the app theme solved the problem for me.

<style name="SearchAutoCompleteTextView" parent="Widget.AppCompat.Light.AutoCompleteTextView">
    <item name="android:textColor">@color/my_text_color</item>
    <item name="android:textColorHint">@color/my_hint_color</item>
</style>

<style name="AppTheme" parent="Theme.AppCompat.Light">
    ...
    <item name="autoCompleteTextViewStyle">@style/SearchAutoCompleteTextView</item>
</style>

这篇关于如何更改SearchView textcolor?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆