【发布时间】:2018-01-20 09:18:44
【问题描述】:
我有简单的实现回收视图。它显示一些项目。 每个项目的布局如下:
<LinearLayout 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="100dp"
android:background="#f00"
android:orientation="vertical"
android:paddingLeft="16dp"
android:paddingRight="16dp">
<TextView/>
</LinearLayout>
我发现问题是:
如果我们将 RecycleView 放在约束布局中 -> 项目视图将 match_parent(使宽度填充父项)-> 确定
所以我的问题是如何解决这个问题? (如何使回收视图在约束布局中正常工作?)。
更新 约束布局视图 https://gist.github.com/quangson91/6fae50f5540f8624e71c9eb2f397dfe3
【问题讨论】:
-
显示
ConstraintLayout的布局xml。 -
是的,我添加了。请看一看。
-
将
FrameLayout的宽度和高度更改为0dp而不是match_parent。 -
对不起,我只是为布局的所有内容创建 gist 文件。
-
请看一下。谢谢
标签: android android-layout android-recyclerview android-constraintlayout