2014-01-15 3 views
1

У меня есть ViewPager, который показывает Fragments, и я хочу, чтобы сверху и просто LinearLayout внизу. Но, Fragments перекрывают макет внизу. Я хочу, чтобы Fragment закончил право на LinearLayout. Смотрите фото:ViewPager/Fragment overlapping LinearLayout внизу

enter image description here

XML с ViewPager

<?xml version="1.0" encoding="utf-8"?> 
<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/steps_pager" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_alignParentTop="true" /> 

<LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" > 

    <Button 
     android:id="@+id/finish_checklist_btn" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:background="@drawable/btn_white_glossy" 
     android:layout_margin="20dp" 
     android:text="@string/finish_checklist" /> 

</LinearLayout> 

XML фрагмента

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:padding="20dp" 
android:background="#fff" > 

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

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" > 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textSize="26sp" 
      android:text="@string/step_order_label" /> 

     <TextView 
      android:id="@+id/step_order" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textSize="26sp" /> 
    </LinearLayout> 

    <View 
     android:layout_width="fill_parent" 
     android:layout_height="1dp" 
     android:background="#000" /> 

    <TextView 
     android:id="@+id/step_name" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:paddingTop="10dp" 
     android:paddingBottom="10dp" 
     android:textSize="26sp" /> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:paddingTop="40dp" 
     android:textSize="20sp" 
     android:text="@string/result_label" /> 

    <TextView 
     android:id="@+id/result" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textSize="20sp" /> 

</LinearLayout> 

<!-- YES/NO BUTTONS --> 
<Button 
    android:id="@+id/button_no" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:background="@drawable/btn_white_glossy" 
    android:padding="20dp" 
    android:visibility="gone" 
    android:text="@string/button_no" /> 

<Button 
    android:id="@+id/button_yes" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_above="@id/button_no" 
    android:background="@drawable/btn_white_glossy" 
    android:padding="20dp" 
    android:layout_marginBottom="30dp" 
    android:visibility="gone" 
    android:text="@string/button_yes" /> 
<!-- END YES/NO BUTTONS --> 

+0

Нужно ли вам, чтобы фрагмент находился над линейной компоновкой? –

ответ

1

Я использовал андроид: layout_below здесь.

layout_below ваш идентификатор ViewPager.

и это расположение в вертикальной

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:gravity="fill_vertical" 
    android:orientation="vertical" > 
0

В all your xml files, должны определить цвет фона для него, он будет решать эту проблему:

Добавить это android:background="@android:color/black" в виде тега вы определили.

p/s: этот случай позволяет избежать перекрытия фона.

Смежные вопросы