PagerTabStrip和PagerTitleStrip

来源:互联网 发布:在线ps源码 编辑:程序博客网 时间:2024/05/16 02:13

先看API:

PagerTitleStrip/PagerTabStrip is a non-interactive indicator of the current, next, and previous pages of a ViewPager. It is intended to be used as a child view of a ViewPager widget in your XML layout. Add it as a child of a ViewPager in your layout file and set its android:layout_gravity to TOP or BOTTOM to pin it to the top or bottom of the ViewPager. The title from each page is supplied by the method getPageTitle(int) in the adapter supplied to the ViewPager.


简单的来说就是这两个控件是放在viewPager中,能够显示当前页,上一页,下一页的一个显示器控件;两者用法一致,只是显示效果会有不同;

效果如下:

PagerTitleStrip:


PagerTabStrip:



用法,直接上代码:

xml代码:

 <android.support.v4.view.ViewPager        android:id="@+id/vp_mainfragment_infolist"        android:layout_width="match_parent"        android:layout_height="match_parent" >        <android.support.v4.view.PagerTitleStrip            android:id="@+id/pts_mainfragment_title"            android:layout_width="match_parent"            android:layout_height="wrap_content"             android:background="#00ff00"            />                <!-- <android.support.v4.view.PagerTabStrip            android:id="@+id/pts_mainfragment_title"            android:layout_width="match_parent"            android:layout_height="wrap_content"             /> -->            </android.support.v4.view.ViewPager>

activity中只要重写pagerAdapter中的getPageTitle()方法即可显示出title;

@Overridepublic CharSequence getPageTitle(int position) {// TODO Auto-generated method stubreturn titles.get(position);}




0 0
原创粉丝点击