您的位置:首页 > 其它

一个强大的开源JPTabBar,快捷,功能强大!

2016-11-17 20:34 127 查看
# JPTabBar

TabBar这个名字相信很多学过一点IOS程序员都知道它是用来干嘛的,但本人也并非擅长开发IOS程序员,只是略懂略懂....这是一个很强大的TabBar,可满足很多需求。用起来也非常简单,在oncreate只调用一行代码就把UI布局和切换页面功能基本都实现了。具体实现的功能,请看效果图:

![

![3.gif](http://upload-images.jianshu.io/upload_images/3417927-88f405b34e51ab57.gif?imageMogr2/auto-orient/strip)

](http://upload-images.jianshu.io/upload_images/3417927-06df76d5a1ea9dc4.gif?imageMogr2/auto-orient/strip)

# 使用方法:

 1.引入Gradle依赖

```Java   

 repositories { 

       jcenter()   

 }   

 dependencies{     

   compile 'com.jpeng:JPTabBar:1.0.4'   

 }

```

2.在你的主页面XML,在适当位置添加下面代码

```

<com.jpeng.jptabbar.JPTabBar   

   android:id="@+id/tabbar"    

   android:layout_width="match_parent" 

   android:layout_height="wrap_content"    

   android:background="#fff"/>

  <!--当然,还有其他自定义结点属性提供给开发者设置-->

```

3.在你的Activity里面声明注解变量。(seleIcons和BadgeModes可以不声明,还有你要确保你全部数组的长度是一样的)

```

    @Titles

    private static final String[] mTitles = {"页面一","页面二","页面三","页面四"};

    @SeleIcons

    private static final int[] mSeleIcons = {R.mipmap.tab1_selected,R.mipmap.tab2_selected,R.mipmap.tab3_selected,R.mipmap.tab4_selected};

    @NorIcons

    private static final int[] mNormalIcons = {R.mipmap.tab1_normal, R.mipmap.tab2_normal, R.mipmap.tab3_normal, R.mipmap.tab4_normal};

    @BadgeModes

    private static final BadgeMode[] mBadgeModes = {BadgeMode.OVAL,BadgeMode.NUMBER,BadgeMode.OVAL,BadgeMode.NUMBER};

```

经过上面的设置后,基本上就可以把一个底部的UI搭建了!

但还有一步,想达到Wechat那种渐变和自动切换ViewPager就使用这个方法。

```

  //调用TabBar的setContainer方法,传入 ? extends ViewPager

  mTabBar.setContainer(mViewpager);

```

其他的,还有很多结点和方法说明,具体在Github:
https://github.com/peng8350/JPTabBar
# 开发者反馈:

假如你有什么需求或者发现BUG,什么的,可以直接发我邮箱:83508440@qq.com,或者直接在Github上issue!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: