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 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 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.
Android appcompat v7 support library Notification compact view repeating buttons issue
You are using the same NotificationCompat.Builder instance to create your Notifications and whenever you add an Action it is added to the previous List and creates an unwanted behavior into the System Api. You have to call clearActions() first on the Builder before adding any if you want to use the same Builder instance.
Related Topics
Android Locationclient Class Is Deprecated But Used in Documentation
Getting the Physical Screen Dimensions/Dpi/Pixel Density in Chrome on Android
Android - Storing/Retrieving Strings with Shared Preferences
Grid of Images Inside Scrollview
What Is Different Between Mainactivity.This VS Getapplicationcontext()
Where Is the Layout Preview in Android Studio
Android Arraylist of Custom Objects - Save to Sharedpreferences - Serializable
How to Execute Async Task Repeatedly After Fixed Time Intervals
How to Add a Textview to a Linearlayout Dynamically in Android
What Is the 'App' Android Xml Namespace
How to Find the Data Usage on a Per-Application Basis on Android
Android Studio - Mergedebugresources Exception
How to _Really_ Programmatically Change Primary and Accent Color in Android Lollipop
Is It a Bad Practice to Use Negative Margins in Android