Giter Site home page Giter Site logo

tabcontainerview's Introduction

TabContainerView (实现底部导航栏效果)

版本 V1.0

image

如何引用

allprojects {
   	repositories {
   		...
   		maven { url 'https://jitpack.io' }
   	}
   }

compile 'com.github.chenpengfei88:TabContainerView:v1.0'

如何使用

 Fragment[] fragments = new Fragment[] {new MainFragment(), new WorkFragment(), new AppFragment(), new MineFragment()};
 TabContainerView tabContainerView = (TabContainerView) findViewById(R.id.tab_containerview_main);
 tabContainerView.setAdapter(new MainTabContainerAdapter(getSupportFragmentManager(), fragments));

常用方法

  //设置当前选中的item
  tabContainerView.setCurrentItem(1);
  
  //设置当前有消息提示的item,提示小圆点
  tabContainerView.setCurrentMessageItem(1);
      
  //设置当前有消息提示的item,提示小圆点,小圆点有消息数量
  tabContainerView.setCurrentMessageItem(1, 3);
  
  //tab切换监听
  tabContainerView.setOnTabSelectedListener(new OnTabSelectedListener() {
       @Override
       public void onTabSelected(Tab tab) {
       }
  });

资源属性

 <declare-styleable name="TabContainerViewStyle">
       <attr name="textSize" format="dimension" />
       <attr name="textColor" format="color" />
       <attr name="selectedTextColor" format="color" />
       <attr name="divideLineColor" format="color" />
       <attr name="divideLineHeight" format="integer" />
 </declare-styleable>

源码逻辑解析

http://www.jianshu.com/p/7cccb5c054da

版本 V2.0

image

从效果图中可以看出V2.0和V1.0的区别

V2.0的Tab UI是可以实现高度定制的,上面的效果图中Tab UI共有三种样式。

V1.0的Tab UI是定死的

如何引用

allprojects {
   	repositories {
   		...
   		maven { url 'https://jitpack.io' }
   	}
   }

compile 'com.github.chenpengfei88:TabContainerView:v2.0'

如何使用

首先创建一个继承自AbsTab类的Tab类(项目中我默认实现了一个DefaultTab),

然后创建一个继承自BaseAdapter类的适配器类(项目中我默认实现了一个DefaultAdapter)

 Fragment[] fragments = new Fragment[] {new MainFragment(), new WorkFragment(), new AppFragment(), new MineFragment()};
 TabContainerView tabContainerView = (TabContainerView) findViewById(R.id.tab_containerview_main);
 tabContainerView.setAdapter(new DefaultAdapter(this, fragments, getSupportFragmentManager(),           getResources().getStringArray(R.array.titleArray),
getResources().getColor(R.color.colorPrimary), iconImageArray, selectedIconImageArray));

常用方法

  //设置当前选中的item
  tabContainerView.setCurrentItem(1);
  
  //设置当前有消息提示的item,提示小圆点
  tabContainerView.setCurrentMessageItem(1);
      
  //设置当前有消息提示的item,提示小圆点,小圆点有消息数量
  tabContainerView.setCurrentMessageItem(1, 3);
  
  //tab切换监听
  tabContainerView.setOnTabSelectedListener(new OnTabSelectedListener() {
       @Override
       public void onTabSelected(Tab tab) {
       }
  });

资源属性

   <declare-styleable name="TabContainerViewStyle">
       <attr name="divideLineColor" format="color" />
       <attr name="divideLineHeight" format="integer" />
   </declare-styleable>

源码逻辑解析

http://www.jianshu.com/p/9aaff43bbf9f

版本 V2.1

如何引用

allprojects {
   	repositories {
   		...
   		maven { url 'https://jitpack.io' }
   	}
   }

compile 'com.github.chenpengfei88:TabContainerView:v2.1'

常用方法

新增 设置tabHost背景颜色 setTabHostBgColor(int bgColor) 方法

tabcontainerview's People

Contributors

chenpengfei88 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.