我有两个ListViews彼此之上:
我几乎用这种布局解决了所有这些要求:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="@null"
android:cacheColorHint="@android:color/transparent"
/>
<ListView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:minHeight="60dp"
android:divider="@null"
android:cacheColorHint="@android:color/transparent"
/>
</LinearLayout>
当第二个ListView为空时,我以编程方式将Visibility设置为Gone以满足第一个要求。
但是当第一个ListView填满时,它将向下推第二个ListView,直到它消失。
我试图通过在第一个ListView变得太大时以编程方式从自定义adaper更改layout_height来解决这个问题。但我的列表项目有不同的大小,所以在将高度更改为固定值后,我不知道如何在添加或更改项目时检测内容高度。
有人知道如何解决这个问题吗?