所以,当应用程序启动时,它显示正确 但是当点击搜索栏时,它会像这样 它堆放在顶部,但有些列表丢失了。 我该如何解决 ? 这是 xml:
<EditText
android:id="@+id/cari"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:hint="Cari Dokumen"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ListView
android:id="@+id/list_view"
android:layout_width="368dp"
android:layout_height="449dp"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="parent"
app:layout_constraintTop_toTopOf="@+id/cari"
/>
最佳答案
将两个 View 包裹在相对布局中
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<EditText
android:id="@+id/cari"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:hint="Cari Dokumen"/>
<ListView
android:id="@+id/list_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/cari"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
/>
</RelativeLayout>
关于java - 如何修复搜索栏中的 ListView ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49064503/