Android覆盖在布局边界之外/之间

我必须添加一个叠加层( ImageView),以便它稍微移动到包含布局左边界的左侧.

做这个的最好方式是什么?

尝试了一些简单的事情,比如将ImageView放在布局中并使用负边距

android:layout_marginLeft="-20dip"

这样做了:

(更正:图像中的文字应为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>

结果

当包含布局的背景图像小于屏幕而不是填充时,也会发生这种情况.

解决方法

使用RelativeLayout而不是LinearLayout(允许重叠)并将其添加到RelativeLayout修复它:
android:clipToPadding="false"

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...