Issue
I am trying to put EditText on top of ListView. Using Relative Layout, both EditText and ListView placed on the screen but text field is mixed with list view on top of page. I added some empty space but did not work. How can I separate edittext and listview. Here is my present code.
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".InvoiceSearchList">
<EditText
android:id="@+id/invoiceSearchFilter"
android:layout_width="match_parent"
android:layout_height="50sp"
android:hint="Search invoice"
/>
<ListView
android:id="@+id/listViewInvoiceSearchList"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
Result screenshot EditText mixed with ListView
Solution
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
android:layout_width="match_parent"
android:layout_height="50dp"
android:id="@+id/et1"></EditText>
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/et1"></ListView>
</RelativeLayout>
Just add ID on the Edit text and set layout_below property to Listview and you are good to go.
Answered By - Rudrik Patel
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.