ViewPager如何设置标题不动
ViewPager如何设置页面可以左右滑动而标题不动,想微信、QQ那样标题不动,求大神告知!
ViewPager如何设置页面可以左右滑动而标题不动,想微信、QQ那样标题不动,求大神告知!
2016-08-05
首先肯定是用的 是底部显示标题。在L布局中再添加一个L布局,这个L布局里面有标题
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content"> <TextView android:layout_gravity="center" android:textSize="30dp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="标题"/> </LinearLayout> <android.support.v4.view.ViewPager android:id="@+id/pager" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center"> <android.support.v4.view.PagerTabStrip android:id="@+id/tab" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom"> </android.support.v4.view.PagerTabStrip> </android.support.v4.view.ViewPager> </LinearLayout>
然后效果图:
满意就采纳吧
举报