小编Anj*_*een的帖子

如何设置RecyclerView的最大高度?

我必须implementinga RecylerView,它应该包含内容,如果它只包含项目内容高度较少.如果项目的增加喜欢250dp,它应该设置为max heght(250dp)并且能够滚动.如何实现这个Relative layout.我的父布局是一个.

这是我的布局文件

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.v7.widget.RecyclerView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/recycler_view"
        android:layout_width="match_parent"
        android:layout_height="250dp"
        android:layout_alignParentBottom="true"
        android:layout_gravity="bottom" />

</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

屏幕截图,如果它只有一个项目.这应该是wrap_content.

屏幕截图,如果它只有一个项目.这应该是wrap_content.

android relativelayout android-layout android-studio

2
推荐指数
1
解决办法
6397
查看次数