2017-10-09 82 views
-1

我在ViewPager的底部有一個固定頁腳。我希望ViewPager的背景在固定頁腳後面溢出,但是ViewPager中的任何內容都不會在固定頁腳後面溢出。這甚至有可能嗎?我有以下佈局。帶固定頁腳的Android viewpager背景

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <android.support.v4.view.ViewPager 
    android:id="@+id/wizard_pager" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" /> 

    <LinearLayout 
    android:id="@+id/button_layout" 
    android:layout_alignParentBottom="true" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:gravity="bottom" 
    android:orientation="vertical"> 

     <TextView 
     android:id="@+id/bottom_separator" 
     android:layout_width="fill_parent" 
     android:layout_height="1px" 
     android:visibility="invisible" /> 

     <FrameLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_marginTop="8dp"> 

      <Button 
      android:id="@+id/wizard_previous" 
      android:layout_width="wrap_content" 
      android:layout_height="fill_parent" 
      android:layout_gravity="start" 
      android:layout_marginBottom="15dp" 
      android:layout_marginStart="15dp" 
      android:textColor="?attr/colorPrimary"/> 

      <FrameLayout 
      android:id="@+id/indicator_container" 
      android:layout_width="wrap_content" 
      android:layout_height="fill_parent" 
      android:layout_gravity="center"/> 

      <Button 
      android:id="@+id/wizard_next" 
      android:layout_width="wrap_content" 
      android:layout_height="fill_parent" 
      android:layout_gravity="end" 
      android:layout_marginBottom="15dp" 
      android:layout_marginEnd="15dp" 
      android:textColor="?attr/colorPrimary"/> 

     </FrameLayout> 
    </LinearLayout> 
</RelativeLayout> 
+0

你到目前爲止試過的東西 –

+0

我試過玩ViewPager的layout_height,但是我得到背景和所有內容溢出在固定頁腳之後,或者頁腳後面沒有溢出的顏色和內容。想知道是否需要爲這種事情創建一個自定義的ViewPager ... – bigfy

+0

你只會通過在viewpager中爲你的內容增加一個很好的底部填充來達到這個目的,爲什麼你不能讓viewpager填充屏幕上方的其餘部分按鈕? –

回答

0

如果您使用RecyclerView作爲您的viewPager和您的頁腳的父級,這將有所幫助。 坐在視圖底部的最後一個視圖應該將其android:layout_alignParentBottom屬性設置爲true ,然後將其與您的父佈局的底部相比,距離您的頁腳高度與android:layout_marginBottom的距離相同或更遠