
Android前后图层
下层是:
要移动下面的图层,但是因为没有遮罩关系所以只能做到这样:
怎么才能做到把上面那个相框外面多出来的图片弄没啊?
用Bitmap和canvas吗?
我试过用xml设置background结果后面图层的图片直接被背景层遮住了…… 展开
感觉不太好办
因为这个相框不是顶着边的,四周有留白,所以没办法单纯的图层叠加。
不过假如只是针对这一种相框的话,倒是可以为这个相框写个独立的xml,像这样
<FrameLayout
android:layout_width="300dip"
android:layout_height="300dip"
>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/bg"
android:layout_marginTop="30dip"
android:layout_marginBottom="30dip"
android:layout_marginLeft="36dp"
android:layout_marginRight="30dp"
android:scaleType="centerCrop"
/>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/front"
/>
</FrameLayout>
其中FrameLayout的width和height可以根据自己的需要去设置
magin的top,bottom,right的值约为Frame边长的1/10(针对留白)
maginLeft在这个基础上大概还要再*1.2(针对相框图左边丝带多出的留白)
效果如下:
如果想要针对不同的相框,你还是上网找找,或者跟你们的UI商量下换成上下左右顶边的那种相框吧……不然除了每种相框写个layout,我暂时想不出什么好办法了

2023-05-10 广告
重新做一下图片吧,用margin做在不同尺寸的屏幕上不好实现,
代码:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/a2"
android:scaleType="fitXY"
/>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/a1"
android:scaleType="fitXY"
/>
</RelativeLayout>