如何使用AppCompat-v7(v21)更改ActionBar中动画ActionBarDrawerToggle图标的颜色?我尝试过这个,但是没有用.谢谢.
myActionBarActivity.java
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mLeftDrawer = (LinearLayout) findViewById(R.id.left_drawer);
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
R.string.drawer_open, R.string.drawer_close)
Run Code Online (Sandbox Code Playgroud)
价值观/ styles.xml
<item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
Run Code Online (Sandbox Code Playgroud)
<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
<item name="spinBars">true</item>
<item name="color">@android:color/black</item>
</style>
Run Code Online (Sandbox Code Playgroud)
更新:解决了,<item name="actionBarWidgetTheme">我的主题中有这个条目可能重叠 <item name="drawerArrowStyle">.我删除了它,现在一切正常.
我用默认导航抽屉创建了一个新活动,但默认颜色是黑色,如何更改?
我试过这段代码有效,但动画没有运行,无法点击
Drawable drawable = getResources().getDrawable(R.drawable.ic_menu);
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.addDrawerListener(toggle);
toggle.syncState();
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
Run Code Online (Sandbox Code Playgroud) android android-studio navigation-drawer android-toolbar android-studio-3.0
android ×1