2017-10-09 158 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的距离相同或更远