gpt4 book ai didi

android - 如何更改AppCompat中工具栏的菜单图标

转载 作者:行者123 更新时间:2023-11-29 01:36:31 25 4
gpt4 key购买 nike

<分区>

我正在尝试做一些非常简单的事情,但我还没有在互联网上或 stackoverflow 上找到任何关于如何解决它的信息。我想更改菜单图标颜色以匹配我的其他图标。我该怎么做?。 ToolbarsetNavigationIconsetLogo 方法不起作用。这是我当前的 Toolbar 的屏幕截图:

enter image description here

这是我在 onCreate 方法中执行的代码。

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_single_naviation_drawer);
mItems = getResources().getStringArray(R.array.nav_drawer_items);
mToolbar = (Toolbar) findViewById(R.id.toolbar);
mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawer.setDrawerShadow(R.drawable.drawer_shadow, Gravity.START);
//For api-21 compatibility
if (mToolbar != null) {
setSupportActionBar(mToolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mDrawerToggle= new ActionBarDrawerToggle(this, mDrawer, mToolbar, R.string.app_name, R.string.app_name);
mDrawer.setDrawerListener(mDrawerToggle);
mToolbar.setNavigationIcon(R.drawable.ic_menu); //Doest work (is the white icon)
mToolbar.setLogo(R.drawable.ic_menu); //Doest work (is the white icon)
}
mToolbar.inflateMenu(R.menu.startup_navigation_drawer);
mContentViewAlreadySet = Boolean.TRUE;

mDrawerList = (ListView) findViewById(R.id.left_drawer);

// Set the adapter for the list view
mDrawerList.setAdapter(new ArrayAdapter<String>(this,
R.layout.drawer_list_item, mItems));
// Set the list's click listener
mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
}

我不在乎我是否在单击它时结束覆盖菜单图标动画,我只希望它与我的其他图标颜色相匹配。

更新:

<resources xmlns:android="http://schemas.android.com/apk/res/android">

<style name="AppTheme.Base" parent="Theme.AppCompat.Light">
<!--<item name="android:buttonStyle">@style/AppTheme.Buttons</item>-->
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="isFloatingWindow">false</item>
<!-- colorPrimary is used, for instance, for the default ActionBar
(but not Toolbar) background.
We specify the same color for the toolbar background in
toolbar.xml.. -->
<item name="colorPrimary">@color/colorPrimary</item>

<!-- colorPrimaryDark is used for the status bar (with the
battery, clock, etc). -->
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>

<!-- colorAccent is used as the default value for
colorControlActivated which is used to tint widgets. -->
<item name="colorAccent">@color/colorSecondary</item>
<item name="android:textColorPrimary">@color/colorSecondary</item>
</style>

<style name="AppTheme" parent="@style/_AppTheme"/>

<style name="_AppTheme" parent="AppTheme.Base">

<item name="android:editTextBackground">@drawable/apptheme_edit_text_holo_light</item>

<item name="android:textColorHighlight">#9980cbc4</item>
<item name="android:textSelectHandleLeft">@drawable/apptheme_text_select_handle_left</item>
<item name="android:textSelectHandleRight">@drawable/apptheme_text_select_handle_right</item>
<item name="android:textSelectHandle">@drawable/apptheme_text_select_handle_middle</item>

<item name="android:autoCompleteTextViewStyle">@style/AutoCompleteTextViewAppTheme</item>

<item name="android:listChoiceIndicatorMultiple">@drawable/apptheme_btn_check_holo_light</item>

<item name="android:listChoiceIndicatorSingle">@drawable/apptheme_btn_radio_holo_light</item>

<item name="android:buttonStyle">@style/ButtonAppTheme</item>

<item name="android:imageButtonStyle">@style/ImageButtonAppTheme</item>

<item name="android:dropDownSpinnerStyle">@style/SpinnerAppTheme</item>

<item name="android:progressBarStyleHorizontal">@style/ProgressBarAppTheme</item>

<item name="android:seekBarStyle">@style/SeekBarAppTheme</item>

<item name="android:ratingBarStyleIndicator">@style/RatingBarBigAppTheme</item>

<item name="android:ratingBarStyleSmall">@style/RatingBarSmallAppTheme</item>

<item name="android:buttonStyleToggle">@style/ToggleAppTheme</item>

<item name="android:listChoiceBackgroundIndicator">@drawable/apptheme_list_selector_holo_light</item>

<item name="android:activatedBackgroundIndicator">@drawable/apptheme_activated_background_holo_light</item>

<item name="android:fastScrollThumbDrawable">@drawable/apptheme_fastscroll_thumb_holo</item>

</style>

</resources>

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com