How is it possible to place a Button over a ListView? Like this image?
I have tried that:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:text="Button" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ListView
android:id="@+id/listView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</ListView>
</LinearLayout>
</FrameLayout>
But the Button is inaccessible…
Both the ListView and the Button must be accessible.
Firstly, you should be using
RelativeLayout;FrameLayoutis used to hold a single child element optimally.Second, the layout is drawn in order from top to bottom -> back to front. Therefore you want your
Buttonbelow it in the XML file.Lastly, instead of
gravityyou should be usingalign.