2

我想爲我的選項卡式活動中的所有片段添加橫幅。橫幅將在頁面底部保持不變。在選項卡式活動中添加橫幅

我在我的項目中有8個頁面,我可以爲所有的片段添加一個橫幅。但是在這個方法中,我必須爲所有片段添加8個橫幅。我不想要它。我想要一個恆定橫幅在底部的所有碎片上。

感謝您的幫助:)

enter image description here

這裏是我的main_activity.xml;

<android.support.design.widget.CoordinatorLayout 
    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" 
    xmlns:ads="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/main_content" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" 
    tools:context="com.example.aslan.rte3.MainActivity"> 




    <android.support.design.widget.AppBarLayout 
     android:id="@+id/appbar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:paddingTop="@dimen/appbar_padding_top" 
     android:theme="@style/AppTheme.AppBarOverlay" 
     android:background="@android:color/black"> 

     <android.support.design.widget.TabLayout 
      android:id="@+id/tabs" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      app:tabGravity="center" 
      app:tabMode="scrollable" /> 

    </android.support.design.widget.AppBarLayout> 


    <android.support.v4.view.ViewPager 
     android:id="@+id/container" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior" 
     android:background="#E0DFDE"> 

    </android.support.v4.view.ViewPager> 






</android.support.design.widget.CoordinatorLayout> 

回答

1

試圖通過這一個

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 

    <android.support.v4.view.ViewPager 
     android:id="@+id/container" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior" 
     android:background="#E0DFDE"> 

    <FrameLayout 
     android:id="@+id/banner_layout" 
     android:layout_width="match_parent" 
     android:layout_height="50dp"> 
     <!-- put your banner here --> 
    </FrameLayout> 
</LinearLayout> 
+0

我這樣做是爲了取代它

<android.support.v4.view.ViewPager android:id="@+id/container" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior" android:background="#E0DFDE"> </android.support.v4.view.ViewPager> 

,但對我的不工作,其顯示空白頁上我screen.Frame佈局總是在頂端,我無法改變它的位置。和控制檯說,沒有足夠的空間來顯示廣告。需要320x50的DP,但只有320x0的DP。 – metomero

+0

您能否提供您的活動佈局? – MaxV

+0

我已將我的xlm文件添加到問題 – metomero

相關問題