【开源】Side-Menu.Android
Side-Menu.Android
- https://github.com/Yalantis/Side-Menu.Android
介绍:
酷炫效果的侧边菜单。运行效果:
![]()
使用说明:
效果来自dribbble上的概念设计 project on dribbble.
依赖Ozodrukh的CircularReveal项目中的动画工具库。
ps 作者的文字实在是不好翻译:
首先你需要用git submodule update 将动画模块上传-初始化命令中你必须创建一个显示在当前Circular Reveal animated view后面的overlay。添加到菜单中的item都必须添加到LinearLayout中。
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
<android.support.v4.widget.DrawerLayout android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent"> <io.codetail.widget.RevealFrameLayout android:id="@+id/conteiner_frame" android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:id="@+id/content_overlay" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"/> <LinearLayout android:id="@+id/content_frame" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"/> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_height="wrap_content" android:layout_width="match_parent" android:minHeight="?attr/actionBarSize" android:background="?attr/colorPrimary"/> </io.codetail.widget.RevealFrameLayout> <ScrollView android:id="@+id/scrollView" android:scrollbarThumbVertical="@android:color/transparent" android:layout_width="80dp" android:layout_height="match_parent" android:layout_gravity="start|bottom"> <LinearLayout android:id="@+id/left_drawer" android:orientation="vertical" android:layout_width="80dp" android:layout_height="wrap_content" android:divider="@android:color/transparent" android:dividerHeight="0dp" android:background="@android:color/transparent"> <!-- Layout of Drawer --> </LinearLayout> </ScrollView></android.support.v4.widget.DrawerLayout> ViewAnimator viewAnimator = new ViewAnimator<>(ActionBarActivity.this, new ArrayList<Resourceble>(), (LinearLayout) findViewById(R.id.left_drawer), contentFragment, drawerLayout); //to open menu you have to override ActionBarDrawerToggle method @Override public void onDrawerSlide(View drawerView, float slideOffset) { super.onDrawerSlide(drawerView, slideOffset); if (slideOffset > 0.6 && viewAnimator.getLinearLayout().getChildCount() == 0) viewAnimator.showMenuContent(); } public void onDrawerClosed(View view) { super.onDrawerClosed(view); viewAnimator.getLinearLayout().removeAllViews(); viewAnimator.getLinearLayout().invalidate(); } |
为了得到menu item的名称和drawable资源,所有的item都必须实现Resourceble 接口。为了得到fragment的截图,所有的fragment都必须实现ScreenShotable接口。
posted on 2015-04-10 10:18 wasdchenhao 阅读(578) 评论(0) 收藏 举报

浙公网安备 33010602011771号