我的XML
文件有一个包含LinearLayout
两个. 但是,当其中一个内容过多时,它会推动另一个并占用其空间。我该怎么做才能让它在一定高度停止推动?我试过添加or但它没有帮助。ListView
android:height="wrap_content"
ListView
ListView
layout-weight
maxHeight
问问题
121 次
3 回答
0
ListViews
如果您想要两个均分的金额相同,只需将它们放在一个LinearLayout
.
LinearLayout
将拥有财产weightSum=2
,而两者都ListViews
将拥有,具体取决于LinearLayout orientation property
:
如果vertical
-> 两者ListViews
都会有android:height="0dp"
和layout-weight=1
如果horizontal
-> 两者ListViews
都会有android:width="0dp"
和layout-weight=1
于 2018-08-16T11:42:50.207 回答
0
尝试这个 :
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/green_bg_duplicate"
android:gravity="center"
android:orientation="vertical"
android:weightSum="2">
<RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1" />
<RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1" />
</LinearLayout>
于 2018-08-16T12:40:06.960 回答
0
我通过编程解决了它。似乎XML
对动态高度没有太多控制。我添加onLayoutChangedListener
了两者ListView
以检测高度变化并在侦听器中添加高度控制逻辑。
于 2018-08-18T07:42:17.133 回答