为了账号安全,请及时绑定邮箱和手机立即绑定

ViewPager如何设置标题不动

ViewPager如何设置页面可以左右滑动而标题不动,想微信、QQ那样标题不动,求大神告知!

正在回答

1 回答

首先肯定是用的 是底部显示标题。在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>

然后效果图:

http://img1.sycdn.imooc.com//57a45b750001e28710801920.jpg


满意就采纳吧

0 回复 有任何疑惑可以回复我~
#1

慕用9969177 提问者

非常感谢!
2016-12-14 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
Android攻城狮的第二门课(第1季)
  • 参与学习       111140    人
  • 解答问题       1560    个

本课程由浅入深地带您学会Android的常用控件的开发和使用

进入课程

ViewPager如何设置标题不动

我要回答 关注问题
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号