java - 如何修复搜索栏中的 ListView

标签 java android

所以,当应用程序启动时,它显示正确 enter image description here 但是当点击搜索栏时,它会像这样 enter image description here 它堆放在顶部,但有些列表丢失了。 我该如何解决 ? 这是 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/

相关文章:

java - 如何从另一个 Maven 模块启动 Spring Boot 应用程序?

java - 不重定向到托管 bean 中指定的新页面

java - 字符串分词器到数组 java

java - Apache Cassandra 中的 DML 是什么?

android - 有人可以为 Google Drive REST API v3 提供最新的 Android 指南吗?

Android:是否可以从共享 Intent 打开浏览器?

java - 如何在运行时覆盖我的 jar 中的 log4j 属性文件

android - Kivy:如何在按钮 on_press 上调用某些东西

java - 如何在 Android 设备上将 WAV 编码为 mp3

Android 分析 : what are FinalizerDaemon, FinalizerWatchDogDaemon、ReferenceQueueDaemon、不同的绑定(bind)器和 JDWP?