Side-Menu.Android的应用
来源:互联网 发布:ext js 学多久 编辑:程序博客网 时间:2024/05/22 20:29
Side-Menu.Android的应用
最近学习了一波android的自带组件,发现原始的ui真是巨丑无比,而自己水平有限,那些超炫酷的交互又不知如何下手,然后就着手寻找一些开源的ui框架,映入眼帘的是交互炫酷的Side-Menu.Android。
简介
Side-Menu.Android是Yalantis 出品的分类侧滑菜单,同时也发现了一款同样是Yalantis出品的Phoenix Pull-to-Refresh-Android,这里不细说,附上github,实现比较简单,,有兴趣的同学可以自行使用。
顺便提醒一下,Yalantis官网放有很多很好看的开源项目哦。
github地址 —— [ Side-Menu.Android ]
github地址 —— [ Phoenix Pull-to-Refresh-Android ]
Yalantis官网 —— [ Yalantis ]
官方使用介绍
First of all you have to upload animation submodule with git submodule update
–init command
Or you can add gradle dependency with command :
dependencies { compile 'com.github.yalantis:Side-Menu.Android:1.0.1'}
and command:
repositories { maven { url "https://jitpack.io" }}dependencies { compile 'com.github.ozodrukh:CircularReveal:(latest-release)@aar'}
To add gradle dependency you need to open build.gradle (in your app folder,not in a project folder) then copy and add the dependencies there in the dependencies block;
for CircularReveal module
After you have to create special overlay layout to show in behind current Circular Reveal
animated view. And to add all items to menu you have to add all of them into LinearLayout
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent"> <io.codetail.widget.RevealFrameLayout android:id="@+id/conteiner_frame" xmlns:android="http://schemas.android.com/apk/res/android" 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(); }
All menu items should implement Resourceble
interface to get menu item name and drawable res And all fragments should implement ScreenShotable
to get screenshot of a fragment
You can customize icons that u place in the menu,or add mor items. Simply by changing the list you parse to view animator .For example:
private List<SlideMenuItem> list = new ArrayList<>(); // the list of menu itemsSlideMenuItem menuItem0 = new SlideMenuItem(ContentFragment.CLOSE, R.drawable.icn_close);list.add(menuItem0);SlideMenuItem menuItem = new SlideMenuItem(ContentFragment.BUILDING, R.drawable.icn_1); //first parameter is the id of menu item,the second is the icon resoucelist.add(menuItem);SlideMenuItem menuItem2 = new SlideMenuItem(ContentFragment.BOOK, R.drawable.icn_2);list.add(menuItem2);viewAnimator = new ViewAnimator<>(this, list, contentFragment, drawerLayout, this);
使用体会
在官网提供的最新版本’com.github.yalantis:Side-Menu.Android:1.0.1’ 中与github提供的项目不一致,移除了SupportAnimator改为Animator
对于android界面开发真是身心俱疲,好麻烦,好佩服google能开发出这么复杂的系统,心力憔悴,继续学习使用。
实际显示效果:
- Side-Menu.Android的应用
- android menu 的简单应用
- Android:Side bar menu 实现收集
- 关于github开源项目Side-Menu.Android的使用详解
- Android开发之Menu的应用
- Android应用中五种常用的menu
- Android应用中五种常用的menu
- Android应用中五种常用的menu
- Android应用中五种常用的menu
- Android入门--Menu的基础应用
- [开源项目]Yalantis/Side-Menu.Android 学习
- 【Android 界面效果28】Android应用中五种常用的menu
- Android应用开发之Menu
- iOS7 side menu new design
- Understanding Ionic’s Side Menu
- Side-Menu源码分析讲解
- Android应用中菜单(Menu)的位置显示问题
- 【Android成长之路】Menu的简单应用
- 迪拜机器人警察上岗 精通6种语言
- 第 15 章 MySQL分布式应用
- .分析以下需求,并用代码实现 1.定义List集合,存入多个字符串 2.删除集合元素字符串中包含0-9数字的字符串 只要字符串中包含0-9中的任意一个数字就需
- 存储过程的优缺点及适宜使用的场合详解
- C#转换Base64编码,解码的URL
- Side-Menu.Android的应用
- 天天写业务代码的程序员怎么成为大牛
- 理解ROC与AUC
- make[1]: *** 没有规则可以创建“all”需要的目标“hello_world.srec”。 停止。
- Kali渗透测试——WOL-E
- javax.el.PropertyNotFoundException: Property 'IdentiNum' not found on type cn.itcast.ssm.pojo.Recomm
- C++随记(二)---动态分配内存问题(1)
- string类型中find和find_first_of
- JavaScript数组