【发布时间】:2015-09-02 02:33:20
【问题描述】:
我有一个可以滑动到 3 个不同页面的 ViewPager。所有 3 个页面都应具有完全相同的标题。
有没有办法在所有 3 个页面上保持相同的标题,这样当我滑动到另一个页面时,标题不会移动/更改,但其余内容会移动/更改?
这是我的 ViewPager 布局:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:fitsSystemWindows="true">
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>
这是我在 ViewPager 上方加载的标题布局:
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="User"
android:layout_gravity="center_vertical" />
</LinearLayout>
这是我膨胀标题的方法:
final ListView listView = (ListView) view.findViewById(R.id.listview);
View header = inflater.inflate(R.layout.header, listView, false);
listView.addHeaderView(header, null, false);
【问题讨论】:
标签: android android-layout android-fragments android-activity android-xml