【发布时间】:2017-03-02 02:11:01
【问题描述】:
如何更改工具栏搜索图标的颜色?我希望它是白色的。我已经用自己的白色可绘制对象进行了更改,但结果仍然是黑色的。我读过this post,但帖子的问题是文本颜色而不是图标颜色。
屏幕截图
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="com.zihadrizkyef.project_katalog_grosirmukenalukis_admin.MainActivity"
android:id="@+id/activity_home"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/myToolbar"
android:layout_height="?android:attr/actionBarSize"
android:layout_width="match_parent"
android:background="@color/colorPrimary"
android:theme="@style/myToolbarTheme"/>
<ListView
android:id="@+id/lvProduct"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
style.xml
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:buttonStyle">@style/MyButtonStyle</item>
</style>
<style name="MyButtonStyle" parent="Base.Widget.AppCompat.Button">
<item name="android:textAllCaps">false</item>
<item name="android:background">@drawable/mybutton</item>
<item name="android:textColor">@color/myWidgetContentColor</item>
</style>
<style name="myToolbarTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:textColorPrimary">@color/myWidgetContentColor</item>
</style>
</resources>
menu_home.xml
<?xml version="1.0" encoding="utf-8"?>
<menu
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_search"
app:showAsAction="always"
app:actionViewClass="android.support.v7.widget.SearchView"
android:title="Search"
android:icon="@drawable/ic_action_search"/>
</menu>
【问题讨论】:
-
你能显示你的菜单文件吗?
-
您是否尝试过为该图标添加色调?
-
你能用 mToolBarTheme 替换它的样式并检查吗?
-
在你的父 AppTheme 样式中添加
- @color/white
-
@himanshu1496 对不起,我忘了把菜单xml放在帖子里
标签: android