android – 如何更改工具栏SearchView下划线颜色为灰色

我在扩展搜索栏时尝试更改搜索视图的下划线颜色

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

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...