2016-12-21 4 views
0

recyclerviewbuttonがあります。これはalignParentBottomです。表示は、recyclerviewの項目の最後の行がボタンによってブロックされていることを除いて、私のrecyclerviewの後に "となり、ボタンの上にはではなく、と表示されます。これをどうすれば解決できますか?あなたが最初のLinear Layoutダウンを移動する必要が上記のalignParentBottomレイアウトの上にrecyclerviewを設定します。

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@color/white_three" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

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

     <android.support.v7.widget.RecyclerView 
      android:id="@+id/orderList" 
      android:layout_height="0dp" 
      android:layout_weight="1" 
      android:layout_width="match_parent"> 
     </android.support.v7.widget.RecyclerView> 

     <TextView 
      android:id="@+id/errorLoadingText" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:textSize="15sp" 
      android:visibility="gone" 
      android:layout_marginTop="120dp" 
      android:gravity="center"/> 

    </LinearLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@color/white_three" 
     android:layout_alignParentBottom="true" 
     android:orientation="vertical"> 

     <TextView 
      android:id="@+id/paymentButtonTop" 
      android:layout_width="match_parent" 
      android:layout_height="43dp" 
      android:background="@drawable/button_radius_toggle_confirm" 
      android:layout_marginTop="15dp" 
      android:layout_marginStart="15dp" 
      android:layout_marginEnd="15dp" 
      android:layout_marginBottom="75dp" 
      android:text="@string/prepayment" 
      android:textColor="@color/warm_grey_two" 
      android:enabled="false" 
      android:textSize="17sp" 
      android:gravity="center" /> 

     <TextView 
      android:id="@+id/paymentButton" 
      android:layout_width="match_parent" 
      android:layout_height="43dp" 
      android:background="@drawable/button_radius_toggle_confirm" 
      android:layout_margin="15dp" 
      android:visibility="gone" 
      android:enabled="false" 
      android:textColor="@color/warm_grey_two" 
      android:text="@string/prepayment" 
      android:textSize="17sp" 
      android:gravity="center" /> 

    </LinearLayout> 

</RelativeLayout> 

答えて

1
リニアレイアウトにあなたの親のレイアウトを変更し

。これにより、望ましい結果が得られます。

XMLファイルは次のようになります。

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@color/white_three" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" 
    android:orientation="vertical"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     android:orientation="vertical"> 

     <android.support.v7.widget.RecyclerView 
      android:id="@+id/orderList" 
      android:layout_height="match_parent" 
      android:layout_width="match_parent"> 
     </android.support.v7.widget.RecyclerView> 

     <TextView 
      android:id="@+id/errorLoadingText" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:textSize="15sp" 
      android:visibility="gone" 
      android:layout_marginTop="120dp" 
      android:gravity="center"/> 

    </LinearLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@color/white_three" 
     android:orientation="vertical"> 

     <TextView 
      android:id="@+id/paymentButtonTop" 
      android:layout_width="match_parent" 
      android:layout_height="43dp" 
      android:background="@drawable/button_radius_toggle_confirm" 
      android:layout_marginTop="15dp" 
      android:layout_marginStart="15dp" 
      android:layout_marginEnd="15dp" 
      android:layout_marginBottom="75dp" 
      android:text="@string/prepayment" 
      android:textColor="@color/warm_grey_two" 
      android:enabled="false" 
      android:textSize="17sp" 
      android:gravity="center" /> 

     <TextView 
      android:id="@+id/paymentButton" 
      android:layout_width="match_parent" 
      android:layout_height="43dp" 
      android:background="@drawable/button_radius_toggle_confirm" 
      android:layout_margin="15dp" 
      android:visibility="gone" 
      android:enabled="false" 
      android:textColor="@color/warm_grey_two" 
      android:text="@string/prepayment" 
      android:textSize="17sp" 
      android:gravity="center" /> 

    </LinearLayout> 

</LinearLayout> 
1

は、ここに私のレイアウトです。 2つの線形レイアウトを切り替えるだけです。

+0

うーんは...試したとボタンが消え、それが今の代わりに背後に隠されています – stackyyflow

2

それはRelativeLayoutデュオのパフォーマンスの問題のLinearLayout内部を持っているのは良い習慣ではありませんが、あなたは下のLinearLayoutに属性android:layout_alignParentBottom="true"を設定することで、トップLinearLayoutandroid:layout_above="@+id/idOfBottomLinearLayout"を設定することによって、欲しいものを達成することができます。コードで

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@color/white_three" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

    <LinearLayout 
     android:layout_above="@+id/bottomLayout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical"> 

     <android.support.v7.widget.RecyclerView 
      android:id="@+id/orderList" 
      android:layout_height="0dp" 
      android:layout_weight="1" 
      android:layout_width="match_parent"/> 

     <TextView 
      android:id="@+id/errorLoadingText" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:textSize="15sp" 
      android:visibility="gone" 
      android:layout_marginTop="120dp" 
      android:gravity="center"/> 

    </LinearLayout> 

    <LinearLayout 
     android:id = "@+id/bottomLayout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@color/white_three" 
     android:layout_alignParentBottom="true" 
     android:orientation="vertical"> 

     <TextView 
      android:id="@+id/paymentButtonTop" 
      android:layout_width="match_parent" 
      android:layout_height="43dp" 
      android:background="@drawable/button_radius_toggle_confirm" 
      android:layout_marginTop="15dp" 
      android:layout_marginStart="15dp" 
      android:layout_marginEnd="15dp" 
      android:layout_marginBottom="75dp" 
      android:text="@string/prepayment" 
      android:textColor="@color/warm_grey_two" 
      android:enabled="false" 
      android:textSize="17sp" 
      android:gravity="center" /> 

     <TextView 
      android:id="@+id/paymentButton" 
      android:layout_width="match_parent" 
      android:layout_height="43dp" 
      android:background="@drawable/button_radius_toggle_confirm" 
      android:layout_margin="15dp" 
      android:visibility="gone" 
      android:enabled="false" 
      android:textColor="@color/warm_grey_two" 
      android:text="@string/prepayment" 
      android:textSize="17sp" 
      android:gravity="center" /> 

    </LinearLayout> 

</RelativeLayout> 
関連する問題