2016-12-21 1 views
0

나는 recyclerview이고 buttonalignParentBottom입니다. 내 recyclerview에 대한 항목의 마지막 행이 내 recyclerview이 ""이고 버튼이 이 아니며 버튼 위에이 아니라는 점을 제외하면 버튼으로 차단되었습니다. 이 문제를 어떻게 해결할 수 있습니까? 먼저 Linear Layout 아래로 이동해야위의 recyclerview 설정 alignParentBottom 레이아웃

<?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

:

여기 내 레이아웃입니다. 선형 레이아웃을 두 개만 전환하면됩니다. 이 RelativeLayout 듀오 성능 문제의 내부 LinearLayout을 가지고 좋은 방법은 아니지만

+0

은 흠 .. 시도하고 버튼이 대신 지금 뒤에 숨겨진, 사라 – stackyyflow

2

, 당신은 당신이 아래의 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> 
관련 문제