Android overlay outside / between layout boundaries

I need to add an overlay (ImageView) so that it moves slightly to the left of the remaining border of the content.

enter image description here

What is the best way to do this?

Tried something simple, like putting an ImageView inside a layout and using a negative margin

android:layout_marginLeft="-20dip" 

This did the following:

enter image description here

(Correction: the text on the image should be 20dip not 20px)

AbsoluteLayout is deprecated. Is there something like z-order? Or what should I do?

Thanks in advance.

Edit: Instead, I tried using a relative layout. The same effect. Here xml is minimized:

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:clipChildren="false" android:paddingLeft="50dip" > <ImageView android:id="@+id/myId" android:layout_width="60dip" android:layout_height="60dip" android:layout_marginLeft="-30dip" android:clipChildren="false" android:src="@drawable/pic" /> </RelativeLayout> 

Result enter image description here

It also happens when the containing layout has a background image smaller than the screen instead of filling.

+7
source share
4 answers

Using RelativeLayout instead of LinearLayout (to allow overlapping) and adding this to RelativeLayout, he fixed this:

 android:clipToPadding="false" 
+13
source

Instead

Android: layout_marginLeft = "- 30dip"

try

Android: paddingLeft = "- 30dp"

+1
source

set "android: clipChildren = false" in xml

0
source

Use a transparent (android: background = "# 00000000") image to the left of the line layout with a width = 30dp. And do myId as left alignment in case of relative layout. If you use a linear layout, make the orientation horizontal and let the transparent image be the first in it.

0
source

All Articles