How can I overlap a button over an ImageView?

android

Solution

You can do that with a Relative Layout, just insert the two childs and position the elements as desired:

<RelativeLayout
    android:id="@+id/imagePreview"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:padding="0dp" >

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/yourImage"
        android:layout_centerInParent="true"/>

    <Button
        android:id="@+id/searchGroupButton"
        android:layout_width="20dp"
        android:layout_height="20dp"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="94dp"
        android:layout_marginTop="15dp"
        android:background="@drawable/icn_delete"
        android:textColor="#fff" />

</RelativeLayout>

Hope it helps!

Regards!

Problem

Hello, to achive a view like the image above that has an attached reomve button i have tried the following xml Linearlayout and setting its background a round image but to achive proportonate picture It would be better to use ImageView, Sorry that my english is not so good but i just wanted to ask how can i achive this by using ImageView in place of LayoutBackground... ``` <LinearLayout android:id="@+id/imagePreview" android:layout_width="140dp" android:layout_height="140dp" android:background="@drawable/profile_image_holder" android:orientation="vertical" android:padding="0dp" > <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" > <Button android:id="@+id/searchGroupButton" android:layout_width="20dp" android:layout_height="20dp" android:layout_marginLeft="94dp" android:layout_marginTop="5dp" android:background="@drawable/icn_delete" android:onClick="removeImage" android:paddingLeft="10dp" android:paddingRight="10dp" android:paddingTop="5dp" android:paddingBottom="0dp" android:textColor="#fff" /> </LinearLayout> </LinearLayout> ```

Original source

Related problems