写demo所用的基本框架,以ViewPager嵌套ViewPager,任意配置菜单

网友投稿 567 2022-11-03

写demo所用的基本框架,以ViewPager嵌套ViewPager,任意配置菜单

写demo所用的基本框架,以ViewPager嵌套ViewPager,任意配置菜单

ayo-menu

写demo所用的基本框架,以ViewPager嵌套ViewPager,任意配置菜单,可以方便的分类罗列demo

没整到jcenter上,暂时就用aar包吧,也挺省劲:- -下来文件名是:ayo-menu-lib-release.aar,拷到libs目录里 然后在build.gradle里引入:

repositories { flatDir { dirs 'libs' }}compile(name:'ayo-menu-lib-release', ext:'aar')

分类菜单功能

用法,继承MainPagerActivity,自己在init()方法里配置菜单

public class MainActivity extends MainPagerActivity { private List

menus; @Override protected void onCreate(Bundle savedInstanceState) { init(); super.onCreate(savedInstanceState); } private void init(){ menus = new ArrayList(); ///--------------------------菜单 Menu m = new Menu("View", R.drawable.weixin_normal, R.drawable.weixin_pressed); menus.add(m); { MenuItem menuItem = new MenuItem("TextView", R.drawable.weixin_normal, R.drawable.weixin_pressed); m.addMenuItem(menuItem); { menuItem.addLeaf(new Leaf("1111", "", null)); menuItem.addLeaf(new Leaf("2222", "", null)); menuItem.addLeaf(new Leaf("3333", "", null)); menuItem.addLeaf(new Leaf("44444", "", null)); menuItem.addLeaf(new Leaf("5666", "", null)); } menuItem = new MenuItem("ImageView", R.drawable.weixin_normal, R.drawable.weixin_pressed); m.addMenuItem(menuItem); { menuItem.addLeaf(new Leaf("1111", "", null)); menuItem.addLeaf(new Leaf("2222", "", null)); menuItem.addLeaf(new Leaf("3333", "", null)); menuItem.addLeaf(new Leaf("44444", "", null)); menuItem.addLeaf(new Leaf("5666", "", null)); } } ///--------------------------菜单 m = new Menu("Layout", R.drawable.weixin_normal, R.drawable.weixin_pressed); menus.add(m); { MenuItem menuItem = new MenuItem("官方", R.drawable.weixin_normal, R.drawable.weixin_pressed); m.addMenuItem(menuItem); { menuItem.addLeaf(new Leaf("1111", "", null)); menuItem.addLeaf(new Leaf("2222", "", null)); menuItem.addLeaf(new Leaf("3333", "", null)); menuItem.addLeaf(new Leaf("44444", "", null)); menuItem.addLeaf(new Leaf("5666", "", null)); } menuItem = new MenuItem("权威第三方", R.drawable.weixin_normal, R.drawable.weixin_pressed); m.addMenuItem(menuItem); { menuItem.addLeaf(new Leaf("1111", "", null)); menuItem.addLeaf(new Leaf("2222", "", null)); menuItem.addLeaf(new Leaf("3333", "", null)); menuItem.addLeaf(new Leaf("44444", "", null)); menuItem.addLeaf(new Leaf("5666", "", null)); } } /////menu finished } @Override public List getMenus() { return menus; }}

注意:

menuItem.addLeaf(new Leaf("1111", "", null));

子模块菜单功能

public class ModuleMenuActivity extends DemoMenuActivity { @Override public DemoInfo[] getDemoMenus() { return new DemoInfo[]{ new DemoInfo("示例1", new View.OnClickListener(){ @Override public void onClick(View v) { Toaster.toastShort("示例1"); } }), new DemoInfo("示例2", new View.OnClickListener(){ @Override public void onClick(View v) { } }) }; }}

3 Toaster:不烦人的Toast

注意初始化:Toaster.init(Application)使用:Toaster.toastShort("示例1");

4 TouchBoard:触摸板

如果你想给你的demo添加一些参数变化的效果,可以使用触摸板,支持click和move事件 注意,click和move应该是冲突的,一次只能关心一个事件

touchBoard_left = findViewById(R.id.touchBoard_left);touchBoard_left.setCallback(new TouchBoard.Callback() { @Override public void onDown(int x, int y) { } @Override public void onUp(int x, int y) { } @Override public void onClick() { onLeftTouchBoardClicked(); } @Override public void onMove(int x, int y, int dx, int dy) { onLeftTouchBoardMove(x, y, dx, dy); }});

5 提供了几个常用的补间动画

没啥大用,对动画感兴趣可以参考这个项目: https://github.com/cowthan/AyoAnim

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:入门指南--玩转实验楼
下一篇:一个万能的android下拉上拉刷新的框架,完美支持recyclerview
相关文章

 发表评论

暂时没有评论,来抢沙发吧~