存储此导航图标的位置?

时间:2017-02-17 08:36:51

标签: android

我刚在Android Studio中创建了一个新项目,我选择了Navigation Drawer Activity

在我做了一些更改后,我意识到我需要将此图标颜色更改为深灰色。因为操作栏背景将为白色。

enter image description here

这个图标png文件存储在哪里?谢谢。

5 个答案:

答案 0 :(得分:2)

如果要更改图标颜色,则需要更改style.xml

<style name="MyMaterialTheme" parent="MyMaterialTheme.Base">

</style>

<style name="MyMaterialTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
</style>

<style name="DrawerArrowStyle" parent="@style/Widget.AppCompat.DrawerArrowToggle">
    <item name="spinBars">true</item>
    <item name="color">@android:color/red</item>
</style>

爪哇

 Toolbar mToolbar = (Toolbar) findViewById(R.id.toolbar);
    mToolbar.setTitle("title");
    setSupportActionBar(mToolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true); 
    getSupportActionBar().setHomeButtonEnabled(true);

答案 1 :(得分:2)

您可以通过为工具栏应用自定义主题来更改图标的颜色。您可以使用以下内容作为参考

<style name="MyMaterialTheme" parent="MyMaterialTheme.Base"/>

<style name="MyMaterialTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="drawerArrowStyle">@style/IconStyle</item>
</style>

<style name="IconStyle" parent="@style/Widget.AppCompat.DrawerArrowToggle">
    <item name="spinBars">true</item>
    <item name="color">@color/your_desired_color</item>
</style>

答案 2 :(得分:2)

如果您创建新项目并选择NavigationDrawerActivity。您可以在R.drawable.ic_drawer行上更改NavigationDrawerFragment.class上的图标抽屉,

public void setUp(int fragmentId, DrawerLayout drawerLayout) {
    mFragmentContainerView = getActivity().findViewById(fragmentId);
    mDrawerLayout = drawerLayout;

    // set a custom shadow that overlays the main content when the drawer opens
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
    // set up the drawer's list view with items and click listener

    ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setHomeButtonEnabled(true);

    // ActionBarDrawerToggle ties together the the proper interactions
    // between the navigation drawer and the action bar app icon.
    mDrawerToggle = new ActionBarDrawerToggle(
            getActivity(),                    /* host Activity */
            mDrawerLayout,                    /* DrawerLayout object */
            R.drawable.ic_drawer,             /* nav drawer image to replace 'Up' caret */
            R.string.navigation_drawer_open,  /* "open drawer" description for accessibility */
            R.string.navigation_drawer_close  /* "close drawer" description for accessibility */

答案 3 :(得分:1)

你可以使用上面的解决方案,但如果你想要图标,你可以在这里https://material.io/icons/#ic_menu获取它,下载你想要的尺寸和颜色

通常所有内置图标都在SDK文件夹中

\sdk\platforms\android-23\data\res\drawable

答案 4 :(得分:1)

您只需要调用它来更改此导航图标的颜色。

toolbar.getNavigationIcon().setColorFilter(Color.DKGRAY, PorterDuff.Mode.MULTIPLY);