【发布时间】:2014-02-04 13:00:04
【问题描述】:
我有包含Fragment 的标签,我想提供滑动手势来左右移动。我在Fragment 和活动内部使用它。我在FragmentTabHost 中使用ViewPager 都来自support.v4 包(需要处理> = API 10)。问题是寻呼机从布局顶部开始显示内容,而 tabhost 先显示选项卡,然后显示内容。我当然想要第二种行为。所以我看到的内容是两次,一次有标签,一次没有。这是我的布局 xml 文件。请注意,我在 tabhost (@+id/relative_header) 上方还有一些其他视图,因此操作栏选项卡不适合这种情况。我已经尝试将寻呼机移动到realtabcontent 或以上,但没有成功。
<android.support.v4.app.FragmentTabHost
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_below="@+id/relative_header" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TabWidget
android:id="@android:id/tabs"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0">
</TabWidget>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="0" />
<FrameLayout
android:id="@+android:id/realtabcontent"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
</android.support.v4.app.FragmentTabHost>
我不确定,但我认为其中一个与另一个不兼容,但我不知道应该使用哪种组合在片段选项卡之间提供滑动手势。知道我做错了什么吗?
【问题讨论】:
标签: android android-fragments android-viewpager android-tabhost android-support-library