0

ConstraintLayoutの中にRecyclerViewがあります。私のScrollViewの下部に大きい空白領域が表示されています

構造はこのようなものです:

<ScrollView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_height="match_parent" 
    android:layout_width="match_parent" 
    android:orientation="vertical" 
    android:fillViewport="true" 
    android:overScrollMode="never"> 


    <android.support.constraint.ConstraintLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical"> 

     <android.support.v7.widget.RecyclerView 
      android:id="@+id/my_list" 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_marginBottom="8dp" 
      android:layout_marginTop="15dp" 
      android:clipToPadding="false" 
      app:layout_constraintBottom_toBottomOf="parent" 
      app:layout_constraintLeft_toLeftOf="parent" 
      app:layout_constraintRight_toRightOf="parent" 
      app:layout_constraintTop_toBottomOf="parent" 
      app:layout_constraintVertical_bias="0.0" /> 
    </android.support.constraint.ConstraintLayout> 
</ScrollView> 

私のコードはRecyclerView、そこに何の問題へのオブジェクトのリストを作成します。唯一の問題は、ScrollViewの下部に大きな空白領域が表示されていることです。理由を理解できません。誰かが私を正しい方向に向けることができますか?前もって感謝します!

(たとえば、リストにオブジェクトが1つしかない場合、ビューをスクロールする必要はありませんが、下部の大きな空白領域をスクロールすることができます)

答えて

0

ScrollViewが失われた場合、RecyclerViewは単独でスクロールできます。

あなたは幅と高さのために(match_constraint)親にすべての側面を制約し、0dpを持っている必要があります ConstraintLayout

によってサポートされていないmatch_parentまた

<android.support.constraint.ConstraintLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 

    <android.support.v7.widget.RecyclerView 
     android:id="@+id/my_list" 
     android:layout_width="0dp" 
     android:layout_height="0dp" 
     app:layout_constraintBottom_toBottomOf="parent" 
     app:layout_constraintLeft_toLeftOf="parent" 
     app:layout_constraintRight_toRightOf="parent" 
     app:layout_constraintTop_toBottomOf="parent" 
     android:layout_marginBottom="8dp" 
     android:layout_marginTop="15dp" 
     android:clipToPadding="false" 
     /> 
</android.support.constraint.ConstraintLayout> 

ノート

あなたConstraintLayoutmatch_parentを持っています幅と高さについて

RecyclerViewの幅と高さは0dpです。これは制約に一致することを意味し、RecyclerViewは親のすべての側に制約があります。

あなたはコンテンツがRecyclerViewためwrap_content代わりのmatch_contentを使用した後、画面

+0

あなたは、対応する要素とのコードスニペットを更新してくださいもらえますか? またはですか? – Leem

+0

更新された回答、確認してください、追加の説明もあります。 – elmorabea

+0

いいえ、これにより、全体のビューはスクロールできません。私はmatch_parentの代わりにRecyclerViewのwrap_contentを使って問題を解決しました。 – Leem

0

に収まるよりである、私の問題を解決し得るときビューがスクロールするRECYCLER。

関連する問題