2

ConstraintLayoutの中にTextViewRecyclerViewという単純なレイアウトがあります。 TextView以下<ConstraintLayout />内の余白が<TextView/>未満

<android.support.constraint.ConstraintLayout 
     android:id="@+id/clSelectedPatient" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <TextView 
      android:id="@+id/tvSelectPatient" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:text="Lifcare" 
      android:textSize="18sp" 
      android:textStyle="bold" 
      android:layout_marginBottom="100dp" 
      app:layout_constraintBottom_toTopOf="@+id/rvPatients" 
      app:layout_constraintTop_toTopOf="parent" /> 

     <android.support.v7.widget.RecyclerView 
      android:id="@+id/rvPatients" 
      android:layout_width="match_parent" 
      android:layout_height="100dp" 
      app:layout_constraintTop_toBottomOf="@+id/tvSelectPatient"/> 

    </android.support.constraint.ConstraintLayout> 

android:layout_marginBottom="100dp"機能していません。

答えて

0

あなたのレイアウトでいくつかのミスがあり、あなたのRecyclerViewに

1

app:layout_constraintBottom_toBottomOf="parent"

を追加します。

  • あなたは幅と使用match_parentためmatch_parentを使用するにはConstraintLayoutのサブビューのために禁止されています。

Build a Responsive UI with ConstraintLayout - Adjust the view size

注:ConstraintLayoutで任意のビューのためにmatch_parentを使用することはできません。 が代わりに適切に縦の余白を表示するために(0dp)

  • 「一致制約」を使用し、あなたはのTextViewとRecyclerViewための垂直制約を定義する必要があります。

あなたの固定レイアウトのコードは次のようになります。

<android.support.constraint.ConstraintLayout 
    android:id="@+id/clSelectedPatient" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 

    <TextView 
     android:id="@+id/tvSelectPatient" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_marginBottom="100dp" 
     android:text="Lifcare" 
     android:textSize="18sp" 
     android:textStyle="bold" 
     app:layout_constraintTop_toTopOf="parent" 
     app:layout_constraintStart_toStartOf="parent" 
     app:layout_constraintEnd_toEndOf="parent" 
     app:layout_constraintBottom_toTopOf="@+id/rvPatients" /> 

    <android.support.v7.widget.RecyclerView 
     android:id="@+id/rvPatients" 
     android:layout_width="0dp" 
     android:layout_height="100dp" 
     app:layout_constraintEnd_toEndOf="parent" 
     app:layout_constraintTop_toBottomOf="@+id/tvSelectPatient" 
     app:layout_constraintStart_toStartOf="parent" 
     app:layout_constraintBottom_toBottomOf="parent" /> 

</android.support.constraint.ConstraintLayout> 

そしてこれは、デバイス上でどのように見えるかです:

enter image description here

関連する問題