动画动作棒材料设计

时间:2014-10-07 07:08:59

标签: android animation android-actionbar android-5.0-lollipop material-design

如何在ActionBar中执行此类动画?

Example animation actionBar material design

4 个答案:

答案 0 :(得分:5)

目前没有公共API来获取此信息。

您可以尝试使用此库:

https://github.com/markushi/android-ui

答案 1 :(得分:4)

我使用了balysv/material-menu库并成功实施。

ActionView By Markushi需要 API级别14 + ,但balysv 的 材质菜单也可以与ActionBarSherLock一起使用用动画定制。

这里有四种图标状态:

BURGER,ARROW,X,CHECK。您可以使用(X,CHECK)进行删除操作,使用(BURGER,ARROW)进行导航抽屉。

enter image description here

我喜欢的另一个功能是按下圆圈动画。这里我们可以选择压制圆形动画和非压制圆形动画。

您可以在滑动抽屉时完全控制动画,

enter image description here

答案 2 :(得分: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

答案 3 :(得分:0)

除了Gabriele Mariotti的回答。

您可能会尝试将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);
}

注意:我自己没有对此进行测试。