No, its not a re asked question I've searched so well. but nowhere found how to do this. I want to change the hamburger icon to back icon by calling a method from my activity. I can do it with Drawer.. but I wanna do it without opening drawer.. for example, when a fragment is shown.. the hamburger will turn into back arrow(with animation) then clicking the back arrow will hide fragment and turn the arrow back into hamburger.
I want the animation while doing this.. is there any way to do that? or its only possible while opening/closing drawer
Thanks in advance
I did it by Calling
onDrawerSlide(View v, float f);
where float value from 0.0f to 1.0f defines the progress of transforming from hamburger to back arrow.
Then I used object animator to call this method 100 times each time float value 0.1 increased and the magic happened. Thank you @gauravsarma for showing me the way.
Do the following
ActionBarDrawerToggle toolbarDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout,
toolbar, R.string.drawer_open, R.string.drawer_close) {
public void onDrawerClosed(View view) {
super.onDrawerClosed(view);
invalidateOptionsMenu();
}
public void onDrawerOpened(View view) {
super.onDrawerOpened(view);
invalidateOptionsMenu();
}
};
drawerLayout.setDrawerListener(toolbarDrawerToggle);
toolbarDrawerToggle.syncState();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.