3

私のアクティビティで、引き出しのトグル アイコンを変更したい ツールバーがあります

 <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>
4

1 に答える 1

31

以下のコード スニペットを使用して、カスタム アクションバー トグル ボタンを設定します。

  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);
                }
            });
于 2015-04-30T06:43:38.457 に答える