EditText now showing under ListView

霸气de小男生 提交于 2019-12-03 09:07:08

Perhaps try doing:

<ListView
    android:layout_height="0dp"
    android:layout_weight="1"
    android:layout_width="fill_parent" android:id="@android:id/list"/>
<EditText
    android:layout_height="wrap_content"
    android:layout_width="fill_parent"
    android:id="@+id/search"
    android:hint="Filter results"/>

That way your ListView will grow to fill only unused space regardless of its own content requirements.

You can use the weight =1 and height 0dp in Listview : As fill_parent is deprecated so use match_parent.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <ListView
        android:id="@android:id/list"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"/>

    <EditText
        android:id="@+id/search"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Filter results" />
</LinearLayout>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!