EditText now showing under ListView

后端 未结 2 1879
天涯浪人
天涯浪人 2021-02-11 07:09

Here is my layout:




        
相关标签:
2条回答
  • 2021-02-11 07:48

    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.

    0 讨论(0)
  • 2021-02-11 07:51

    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>
    
    0 讨论(0)
提交回复
热议问题