How to add overlay view over other view in android?
27,087
Set as background!
Just kidding... what you need is put your views inside a RelativeLayout
. Something like will work:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:text="blah blah"/>
</RelativeLayout>
Notice the use of params like layout_alignParentLeft
which are used to position the view where you want.
Author by
Urban
Updated on July 09, 2022Comments
-
Urban almost 2 years
I want to put button above image view.
How can i do this?
(Please, don't offer to set Background, cause i need ImageView)
-
William over 13 yearsYou can also use merge (developer.android.com/resources/articles/…) or a framelayout (developer.android.com/resources/articles/…)
-
cracked_all over 11 yearsThe above link is dead now, try this instead: developer.android.com/training/improving-layouts/…