如何更改工具欄搜索圖標顏色?我希望它是白色的。我用我自己的白色drawable改變了,但結果仍然是黑色的。我讀過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>
你能證明你的菜單文件? – himanshu1496
您是否嘗試過給該圖標添加色調顏色? –
你可以用mToolBarTheme替換它,並檢查它嗎? – ImGenie