我需要实现一个RecylerView
,如果它只包含内容高度较小的项,则应该将其包装。如果项增加到像250dp
这样的大小,则应将其设置为最大的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>
如果只有一个项目,截图应为wrap_content。
ScrollView
作为父布局。 - AlphaQScrollView
中使用RelativeLayout
或当前Relative layout
代替。 - Anjal Saneen