android显示布局边界的边距,Android的覆盖外/布局边界之间

I have to add an overlay (ImageView) so that it's a bit shifted to the left of the containing layout's left boundary.

O1Jbf.png

What is the best way to do this?

Tried something simple, like putting the ImageView inside the layout and use negative margin

android:layout_marginLeft="-20dip"

This made this:

eclPA.png

(Correction: Text in the image should be 20dip not 20px)

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

Thanks in advance.

Edit: I tried using relative layout instead. Same effect. Here's the xml reduced to a minimum:

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:clipChildren="false"

android:paddingLeft="50dip"

>

android:id="@+id/myId"

android:layout_width="60dip"

android:layout_height="60dip"

android:layout_marginLeft="-30dip"

android:clipChildren="false"

android:src="@drawable/pic" />

Result

0oNdo.png

Also happens when the containing layout has a background image smaller than the screen instead of padding.

解决方案

Using RelativeLayout instead of LinearLayout (to allow overlapping) and adding this to the RelativeLayout fixed it:

android:clipToPadding="false"

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值