4
A
回答
5
0
除了加布里埃莱马里奥蒂的答案。
你可能会尝试用他提到的库替换android.R.id.home和ActionView
。
查找视图,并替换:
private void replaceHomeView(Activity activity){
View homeView;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
Resources resources = activity.getResources();
int id = resources.getIdentifier("android:id/home", null, null);
homeView = activity.getWindow().getDecorView().findViewById(id);
} else {
homeView = activity.getWindow().getDecorView().findViewById(R.id.home);
}
replace(homeView);
}
卸下并更换主图标ImageView
:
private replace(View home){
ViewGroup parent = (ViewGroup) view.getParent();
int homeIndex = parent.indexOfChild(view);
ActionView newHome = new ActionView(home.getContext));
newHome.setId(home.getId());
parent.removeView(home);
parent.addView(newHome, homeIndex);
}
注:我没有这个测试自己。
4
我已经使用balysv/material-menu库并成功实施。
ActionView By Markushi要求API级别14+但通过balysv材料菜单可以与ActionBarSherLock
使用也与动画定制。
在这里,你有四个图标状态:
BURGER,ARROW,X,检查。对于导航抽屉,您可以使用(X,CHECK)进行删除操作并使用(BURGER,ARROW)。
还有一个功能,我喜欢的是压圆动画。在这里,我们可以选择按压圆形动画和非按压圆形动画。
您可以完全控制动画,同时滑动这样的抽屉,
3
Android的支持库V7的ActionBarDrawerToggle有动画。
https://developer.android.com/reference/android/support/v7/app/ActionBarDrawerToggle.html
下面是支持库V7添加到项目中的指令。 https://developer.android.com/tools/support-library/setup.html