Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了在Android工具栏中更改背面和清除图标的SearchView颜色大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我想在SearchView崩溃时自定义后退和清除图标.我的要求是将颜色更改为白色,但现在是黑色.(请参阅下面分享的图像).我希望解决这个问题几天,但我尝试过的解决方案都没有解决.我尝试了几个从SO建议的解决方案,如下所示:

解决方案1:

<style name="AppTheme" parent="@style/Theme.base.AppCompat.Light.DarkActionBar">
    <item name="actionBarWidgetTheme">@style/YourActionBarWidget</item>
</style>

<style name="YourActionBarWidget" parent="@style/Theme.AppCompat">
    <item name="searchViewCloseIcon">@drawable/xxx</item>
</style>

解决方案2:

final Drawable upArrow = getresources().getDrawable(R.drawable.abc_ic_ab_BACk_mtrl_am_alpha);
upArrow.setColorFilter(getresources().getColor(R.color.WHITE),PorterDuff.Mode.SRC_ATOp);
getSupportActionBar().setHomeAsUpInDicator(upArrow);

我的项目styles.xml

<style name="ToolBarTheme" parent="@style/Theme.AppCompat.Light">
        <item name="colorPriMary">@color/blue</item>
        <item name="colorPriMaryDark">@color/blue</item>
        <item name="windowNotitle">true</item>
        <item name="windowActionBar">false</item>
        <item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
        <item name="android:itemTextAppearance">@style/myCustomMenuTextApearance</item>
        <item name="android:actionMenuTextColor">@color/white</item>
        <item name="actionMenuTextColor">@color/white</item>

    </style>



<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
        <item name="spinBars">true</item>
        <item name="color">@color/white</item>
        <item name="gapbetweenBars">2.5dip</item>
        <item name="thickness">2dp</item>
    </style>

我的确切问题的屏幕截图:

请帮我解决我的问题.任何类型的解决方案和建议对我都有帮助.感谢您的支持.

解决方法@H_618_22@
如果您在工具栏上搜索白色图标
在工具栏标签添加这些
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"

大佬总结

以上是大佬教程为你收集整理的在Android工具栏中更改背面和清除图标的SearchView颜色全部内容,希望文章能够帮你解决在Android工具栏中更改背面和清除图标的SearchView颜色所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。