Android 片段在ViewPager中重叠
我在Android的PageViewer中得到了重叠的片段 PFB页面查看器的我的布局Android 片段在ViewPager中重叠,android,android-fragments,android-viewpager,baseadapter,Android,Android Fragments,Android Viewpager,Baseadapter,我在Android的PageViewer中得到了重叠的片段 PFB页面查看器的我的布局 <TabHost android:id="@android:id/tabhost" android:layout_width="fill_parent" android:layout_height="900dp" android:layout_alignParentBottom="true" > <RelativeLayout andro
<TabHost
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="900dp"
android:layout_alignParentBottom="true" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@android:id/tabs" >
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</android.support.v4.view.ViewPager>
</FrameLayout>
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal" >
</TabWidget>
</RelativeLayout>
</TabHost>
我的片段被调用,但它在viewpager上重叠。
选项卡从新片段的下方运行。好心帮忙
事后来看,我认为嵌套片段或子片段应该发挥作用。请引导。我使用了查看寻呼机,从PagerAdapter扩展而来。我认为您没有引用正确的布局,您使用的是id/tabcontent。我可以举一个我所做的例子,我想你也可以效仿 在片段xml中:
<LinearLayout
...
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="1"
android:background="@android:color/white" />
...
</LinearLayout>
在ViewPager代码中
@Override
public Object instantiateItem(ViewGroup container, int position) {
...
View view = getActivity().getLayoutInflater().inflate(R.layout.pager_item, container, false);
...
return view
}
注意:我没有使用FragmentTransaction类来显示片段或选项卡视图
请随时通知我们……您对“FrameLayout”和“android.support.v4.view.ViewPager”做了什么?这两个选项在您的情况下都不同。对了,我有4个选项卡,使用ViewPager,我在每个选项卡上滚动这些选项卡,我为每个选项卡显示了单独的片段,那么“FrameLayout”是什么,您是否尝试添加片段?我不理解您使用ViewPager@OriginalAndroid:我在total Developments@ProjectAndroid上发布了一个备选问题,这几乎就像对同一个“备选”问题回答了两次。也许最好只是编辑你原来的问题,尽管有很多变化。这样就保留了许多评论。你认为我现在发布的答案有帮助吗?
mViewPager = (ViewPager) view.findViewById(R.id.viewpager);
@Override
public Object instantiateItem(ViewGroup container, int position) {
...
View view = getActivity().getLayoutInflater().inflate(R.layout.pager_item, container, false);
...
return view
}