Giter Club home page Giter Club logo

android-viewpagerindicator's Introduction

Android-ViewPagerIndicator

一款仿MIUI的ViewPagerIndicator,支持Tab数量随意定义。

效果图

固定tab数量

Sample Screenshots

非固定tab数量

Sample Screenshots

用法

代码生成tab

mIndicator.setVisibleTabCount(4);//设置可见Tab数量
mIndicator.setTabItemTitles(mDatas);//设置tab标题
mViewPager.setAdapter(mAdapter);
mIndicator.setViewPager(mViewPager,0);//绑定ViewPager

直接布局中书写

布局中编写,则代码中只需要绑定ViewPager一行代码。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:zhy="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffffff"
android:orientation="vertical" >

<com.zhy.view.ViewPagerIndicator
    android:id="@+id/id_indicator"
    android:layout_width="match_parent"
    android:layout_height="45dp"
    android:background="@drawable/title_bar_bg_one_row"
    android:orientation="horizontal"
    zhy:visible_tab_count="3" >

    <TextView
        android:layout_width="0dp"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:gravity="center"
        android:text="短信1"
        android:textColor="#CCFFFFFF"
        android:textSize="16sp" />

    <TextView
        android:layout_width="0dp"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:gravity="center"
        android:text="收藏2"
        android:textColor="#CCFFFFFF"
        android:textSize="16sp" />

    <TextView
        android:layout_width="0dp"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:gravity="center"
        android:text="推荐3"
        android:textColor="#CCFFFFFF"
        android:textSize="16sp" />

    <TextView
        android:layout_width="0dp"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:gravity="center"
        android:text="推荐4"
        android:textColor="#CCFFFFFF"
        android:textSize="16sp" />
 </com.zhy.view.ViewPagerIndicator>

    <android.support.v4.view.ViewPager
	android:id="@+id/id_vp"
	android:layout_width="match_parent"
	android:layout_height="0dp"
	android:layout_weight="1" >
    </android.support.v4.view.ViewPager>

</LinearLayout>

#关于我

我的博客地址

android-viewpagerindicator's People

Contributors

hongyangandroid avatar

Watchers

 avatar  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.