如何改变工具栏搜索查看下划线的颜色以灰色
问题描述:
我试图改变搜索视图的下划线颜色,当我们扩大搜索bar`如何改变工具栏搜索查看下划线的颜色以灰色
SearchView.SearchAutoComplete autoCompleteTextView = (SearchView.SearchAutoComplete) searchView.findViewById(R.id.search_src_text);
autoCompleteTextView.setCursorVisible(true);
autoCompleteTextView.setTextColor(ContextCompat.getColor(this, R.color.textcolor_light_gray));
autoCompleteTextView.setHintTextColor(autoCompleteTextView.getTextColors().withAlpha(255));
autoCompleteTextView.setTextSize(16);
View searchplate = (View)searchView.findViewById(android.support.v7.appcompat.R.id.search_plate);
searchplate.setBackgroundResource(R.drawable.autocomplete_bg);
在这里,我使用的主题来改变颜色也
<style name="MySearchViewStyle" parent="Widget.AppCompat.Light.SearchView">
<!-- Background for the search query section (e.g. EditText) -->
<item name="queryBackground">@color/darkgray</item>
</style>
但没有为我工作。任何一个可以帮助我请...
答
最后我得到了解决..
View searchplate = (View)searchView.findViewById(android.support.v7.appcompat.R.id.search_plate);
searchplate.getBackground().setColorFilter(Color.DKGRAY, PorterDuff.Mode.MULTIPLY);
答
您可以通过XML还改变:
<item name="android:queryBackground">...</item>
我想你忘记android:
前缀
我们可以通过xml执行相同的操作吗? 主题或风格? – ihsan
NO。我只尝试过主题或风格,但它没有工作。所以只有我加了彩色滤镜 – sree