【发布时间】:2017-05-22 03:20:16
【问题描述】:
我必须implementing 一个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作为父布局。 -
@AlphaQ
ScrollView而不是RelativeLayout或当前Relative layout内ScrollView -
谷歌为什么要删除maxHeight,这样做真的很不方便。
标签: android android-layout android-studio android-relativelayout