【问题标题】:How can I change the actionbardrawertoggle icon, android?我怎样才能改变actionbardrawertoggle图标,android?
【发布时间】:2015-04-30 06:27:37
【问题描述】:

在我的活动中,我想更改抽屉切换图标 我有我的工具栏

 <android.support.v7.widget.Toolbar
    android:id="@+id/tool_bar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:background="@color/appColor"
    android:minHeight="?attr/actionBarSize"
    app:theme="@style/MyDarkToolbarStyle">


</android.support.v7.widget.Toolbar>

这是工具栏主题

 <style name="MyDarkToolbarStyle" parent="Widget.AppCompat.Toolbar">
    <item name="android:gravity">center_vertical</item>
    <!--<item name="popupTheme">@style/PopupMenuStyle</item>-->
    <item name="actionButtonStyle">@style/MyActionButtonStyle</item>

</style>

这是活动主题

 <style name="MyMaterialTheme.Base" parent="Theme.AppCompat">
    <item name="android:windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
    <item name="colorPrimary">@color/ColorPrimary</item>
    <item name="colorPrimaryDark">@color/ColorPrimaryDark</item>
</style>

【问题讨论】:

标签: android navigation-drawer actionbardrawertoggle


【解决方案1】:

使用下面的代码 sn-p 设置您的自定义操作栏切换按钮。

  mDrawerToggle.setDrawerIndicatorEnabled(false);

            // mDrawerToggle.setHomeAsUpIndicator(R.drawable.menu_icon);
            mToolbar.setNavigationIcon(R.drawable.menu_icon);

            mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    mDrawerLayout.openDrawer(Gravity.LEFT);
                }
            });

【讨论】:

    猜你喜欢
    • 2022-10-01
    • 1970-01-01
    • 2022-07-07
    • 2012-04-08
    • 2019-01-30
    • 1970-01-01
    • 1970-01-01
    • 2014-09-08
    • 1970-01-01
    相关资源
    最近更新 更多