我必须添加一个叠加层(ImageView),使其稍微偏移到包含布局左边界的左侧.

做这个的最好方式是什么?
尝试了一些简单的事情,比如将ImageView放在布局中并使用负边距
android:layout_marginLeft="-20dip"
Run Code Online (Sandbox Code Playgroud)
这样做了:

(更正:图像中的文字应为20dip而不是20px)
不推荐使用AbsoluteLayout.是否有像z-order这样的东西?或者我该怎么办?
提前致谢.
编辑:我尝试使用相对布局.同样的效果.这里的xml减少到最低限度:
<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>
Run Code Online (Sandbox Code Playgroud)
结果

当包含布局的背景图像小于屏幕而不是填充时,也会发生这种情况.
Ixx*_*Ixx 14
使用RelativeLayout而不是LinearLayout(允许重叠)并将其添加到RelativeLayout修复它:
android:clipToPadding="false"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9880 次 |
| 最近记录: |