How to style the DrawerArrowToggle from Android appcompat v7 21 library
The following works for me:
<style name="MyTheme" parent="Theme.AppCompat">
<item name="drawerArrowStyle">@style/MyDrawerArrowToggle</item>
</style>
<style name="MyDrawerArrowToggle" parent="Widget.AppCompat.DrawerArrowToggle">
<item name="color">@color/your_color</item>
</style>
How to implement DrawerArrowToggle from Android appcompat v7 21 library
First, you should know now the android.support.v4.app.ActionBarDrawerToggle
is deprecated.
You must replace that with android.support.v7.app.ActionBarDrawerToggle
.
Here is my example and I use the new Toolbar
to replace the ActionBar
.
MainActivity.java
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar mToolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(mToolbar);
DrawerLayout mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle mDrawerToggle = new ActionBarDrawerToggle(
this, mDrawerLayout, mToolbar,
R.string.navigation_drawer_open, R.string.navigation_drawer_close
);
mDrawerLayout.setDrawerListener(mDrawerToggle);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
mDrawerToggle.syncState();
}
styles.xml
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
</style>
<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
<item name="spinBars">true</item>
<item name="color">@android:color/white</item>
</style>
You can read the documents on AndroidDocument#DrawerArrowToggle_spinBars
This attribute is the key to implement the menu-to-arrow animation.
public static int DrawerArrowToggle_spinBars
Whether bars should rotate or not during transition
Must be a boolean value, either "true" or "false".
So, you set this: <item name="spinBars">true</item>
.
Then the animation can be presented.
Hope this can help you.
How to style ActionBar back icon from Android appcompat v7 21 library
You can use ActionBar to change icon with this method.
ab.setDisplayHomeAsUpEnabled(true);
ab.setHomeAsUpIndicator(R.drawable.ic_back_arrow);
ab.show();
with this you can set back icon whatever u want.
How to change the menu icon of a Toolbar in AppCompat
If you want to match the color only:
In your app theme set the
<item name="colorAccent">@color/whatever</item>
Appcombat v7 Toolbar with drawer changing colors
Finally made it by doing this on my theme.xml file
<style name="AppTheme" parent="Theme.AppCompat.Light">
....
<item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
</style>
<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
<item name="spinBars">true</item>
<item name="color">@android:color/white</item>
</style>
Related Topics
What's Oncreate(Bundle Savedinstancestate)
Add "View More" at the End of Textview After 3 Lines
Android App Crashes When Launched in Debug Mode
Determine Addaction Click for Android Notifications
Error Strictmode$Androidblockguardpolicy.Onnetwork
How to Force the Action Bar to Be at the Bottom in Ics
Visual Studio (2015) Emulator for Android Not Working - Xde.Exe - Exit Code 3
How to Use Custom Permissions in Android
How to Use Getsystemservice in a Non-Activity Class (Locationmanager)
Drawerlayout Double Drawer (Left and Right Drawers Simultaneously)
How to Detect Device Is Android Phone or Android Tablet
How to Change a Layer-List Drawable
Import .CSV File to SQLite in Android
Manually Put Files to Android Emulator Sd Card
Android Studio Gradle Icon Error, Manifest Merger
Place 2 Textview Beside Each Other with 2Nd Textview Always Visible