问题描述
我要补充的覆盖(ImageView的),因此这是一个有点转移到含有布局的左边界的左侧。
I have to add an overlay (ImageView) so that it's a bit shifted to the left of the containing layout's left boundary.
什么是做到这一点的最好方法是什么?
What is the best way to do this?
试过了简单的东西,就像把ImageView的里面的布置和使用负保证金
Tried something simple, like putting the ImageView inside the layout and use negative margin
android:layout_marginLeft="-20dip"
这使这个:
(更正:图像中的文本应该是20dip不是20像素)
(Correction: Text in the image should be 20dip not 20px)
AbsoluteLayout是德precated。有什么样的Z顺序?或者,我该怎么办?
AbsoluteLayout is deprecated. Is there something like z-order? Or what do I do?
在此先感谢。
编辑:我试图用相对布局来代替。同样的效果。这里的XML减少到最低限度:
I tried using relative layout instead. Same effect. Here's the xml reduced to a minimum:
<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
另外发生在当含有布局具有背景图像比屏幕代替填充较小
Also happens when the containing layout has a background image smaller than the screen instead of padding.
推荐答案
使用RelativeLayout的代替的LinearLayout(允许重叠),加入这对RelativeLayout的固定它:
Using RelativeLayout instead of LinearLayout (to allow overlapping) and adding this to the RelativeLayout fixed it:
android:clipToPadding="false"
这篇关于Android的覆盖外/布局边界之间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!