2014-09-26 51 views
0

我想有一个视图 在哪里首先会有adview在片段和最后与botton android pagertabstrip将存在,但不知何故pagertabstip采取整页。 我的代码如下android分页器标签带在底部采取整个片段

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@color/black" > 

<LinearLayout 
    android:id="@+id/adview" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="@color/black" 
    android:orientation="vertical" > 
</LinearLayout> 

<android.support.v4.view.ViewPager 
    android:id="@+id/pager" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_above="@+id/tabs" 
    android:layout_below="@+id/adview" 
    tools:context=".MainActivity" /> 

<com.astuetz.PagerSlidingTabStrip 
    android:id="@+id/tabs" 
    android:layout_width="match_parent" 
    android:layout_height="48dip" 
    android:layout_alignParentBottom="true" 
    android:layout_below="@+id/adview" 
    android:background="@color/black" > 
</com.astuetz.PagerSlidingTabStrip> 

</RelativeLayout> 

如何使这项工作,与标签栏底部和寻呼机查看顶部,

回答

3

你应该使用layout_gravity="bottom",因为ViewPager延伸FrameLayout,所以它是FrameLayout使用相同的参数。 android:layout_alignParentBottomRelativeLayout

编辑:

重读你的问题,你的XML。我还以为你使用标准PagerTabStrip from the support library,但是这是你想要的东西:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@color/black" > 

<LinearLayout 
    android:id="@+id/adview" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="@color/black" 
    android:orientation="vertical" > 
</LinearLayout> 

<android.support.v4.view.ViewPager 
    android:id="@+id/pager" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_above="@+id/tabs" 
    android:layout_below="@+id/adview" 
    tools:context=".MainActivity" /> 

<com.astuetz.PagerSlidingTabStrip 
    android:id="@+id/tabs" 
    android:layout_width="match_parent" 
    android:layout_height="48dip" 
    android:layout_alignParentBottom="true" 
    android:background="@color/black" > 
</com.astuetz.PagerSlidingTabStrip> 

</RelativeLayout> 

从标签中取出android:layout_below="@+id/adview"。这使标签在adview之后立即开始。

+0

喜它是在相对布局,因为我想的AdView浮在片段 – 2014-09-26 12:30:29

+1

我念错了你的问题,我编辑我的答案。现在应该是正确的。 – Budius 2014-09-26 12:37:04

+0

thankx很多,它的工作像一个魔术,似乎我不明白如何相对查看工作:( – 2014-09-26 12:40:04

0

使用 - layout_gravity="bottom"

为什么?因为,FrameLayoutViewPager

+0

嗨它是在相对布局,因为我想adfl浮动片段, – 2014-09-26 12:28:52

1

使用该扩展:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="@color/black" 
android:orientation="vertical" > 

<LinearLayout 
    android:id="@+id/adview" 
    android:layout_width="match_parent" 
    android:layout_height="50dp" 
    android:background="@color/black" 
    android:orientation="vertical" > 
</LinearLayout> 

<android.support.v4.view.ViewPager 
    android:id="@+id/pager" 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_weight="0.9" 
    android:background="#ff0000" 
    tools:context=".MainActivity" /> 

<com.astuetz.PagerSlidingTabStrip 
    android:id="@+id/tabs" 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_weight="0.1" 
    android:background="@color/black" > 
</com.astuetz.PagerSlidingTabStrip> 

</LinearLayout> 
+0

其工作也,但adview不漂浮在viewpager。谢谢你帮我 – 2014-09-26 12:41:42