Animation actionBar material design

2019-03-16 18:33发布

4条回答
▲ chillily
2楼-- · 2019-03-16 18:39

I have used balysv/material-menu library and implemented successfully.

ActionView By Markushi requires API level 14+ but material-menu by balysv can be used with ActionBarSherLock also with animation customization.

Here you have four icon states:

BURGER, ARROW, X, CHECK. You can use (X, CHECK) for delete operation and (BURGER, ARROW) for navigation drawer.

enter image description here

One more feature that i like is pressed circle animation. Here we have choice between pressed circle animation and non-pressed circle animation.

You can have full control of animation while sliding a drawer like this,

enter image description here

查看更多
兄弟一词,经得起流年.
3楼-- · 2019-03-16 18:48

In addition to Gabriele Mariotti's answer.

You might try to replace android.R.id.home with the ActionView from the library he mentioned.

Find the view and replace it:

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);

}

Remove and replace home icon 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);
}

Note: I haven't tested this myself.

查看更多
虎瘦雄心在
4楼-- · 2019-03-16 18:54

Currently there isn't public API to obtain this.

You can try this library:

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

查看更多
手持菜刀,她持情操
5楼-- · 2019-03-16 18:59

Android Support Library v7's ActionBarDrawerToggle has that animation.

https://developer.android.com/reference/android/support/v7/app/ActionBarDrawerToggle.html

Here is the instruction to add support library v7 to your project. https://developer.android.com/tools/support-library/setup.html

查看更多
登录 后发表回答