Legen Sie die maximale Höhe von RecyclerView fest


Führen Sie die ConstraintLayout-Bibliothek in build.gradle über die ConstraintLayout-Einstellungen ein

    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

Legen Sie das übergeordnete Layout von RecyclerView auf ConstraintLayout fest, legen Sie die Höhe von RecyclerView auf 0 dp fest, fügen Sie die Attribute „layout_constraintHeight_min“ und „layout_constraintHeight_max“ hinzu und geben Sie die entsprechende Höhe an

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/new_focus_recycler_view"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_marginTop="11dp"
        android:overScrollMode="never"
        android:scrollbars="none"
        app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
        app:layout_constraintTop_toBottomOf="@+id/tv_new_focus"
        app:layout_constraintHeight_min="100dp"
        app:layout_constraintHeight_max="230dp" />

Wenn die RecyclerView mehrere Elemente enthält, kann ihre Höhe auf diese Weise höchstens 230 dp anzeigen, und andere Elemente können durch Verschieben angezeigt werden.

Je suppose que tu aimes

Origine blog.csdn.net/Billy_Zuo/article/details/131707822
conseillé
Classement