我用下面的下面的code圆RelativeLayout的的角落。我保存为 mybackground.xml
在绘制
文件夹。
它的正常工作四舍五入的角落,但问题是,我也想添加一个透明的图片作为我的RelativeLayout的一个背景。如何能够做到两件事?我如何使用图像和绘制XML(四舍五入角落),同时为RelativeLayout的......
< XML版本=1.0编码=UTF-8&GT?;
<形状的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:形状=矩形机器人:填充=10dp>
<边角安卓bottomRightRadius =30dp
机器人:bottomLeftRadius =30dp
机器人:topLeftRadius =30dp
机器人:topRightRadius =30dp/>
< /形状>
解决方案
您可以使用的层列表
这会是这样
< XML版本=1.0编码=UTF-8&GT?;
<层列表的xmlns:机器人=http://schemas.android.com/apk/res/android>
<项目>
<形机器人:形状=矩形机器人:填充=10dp>
<边角安卓bottomRightRadius =30dp
机器人:bottomLeftRadius =30dp机器人:topLeftRadius =30dp
机器人:topRightRadius =30dp/>
< /形状>
< /项目>
<项目><! - 你的透明图像 - >< /项目>
< /层列表>
I am using the following below code to round the corners of RelativeLayout. I save this as mybackground.xml
in drawable
folder.
It's working fine for rounding the corner but the problem is that I also want to add an transparent image as a background of my RelativeLayout. How can I achieve both things? How can I use an image and a drawable xml (for rounding the corner) at the same time for a RelativeLayout ...
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" android:padding="10dp">
<corners android:bottomRightRadius="30dp"
android:bottomLeftRadius="30dp"
android:topLeftRadius="30dp"
android:topRightRadius="30dp" />
</shape>
解决方案
You can use Layer-List
It will be like this
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle" android:padding="10dp">
<corners android:bottomRightRadius="30dp"
android:bottomLeftRadius="30dp" android:topLeftRadius="30dp"
android:topRightRadius="30dp" />
</shape>
</item>
<item><!-- your transparent image --></item>
</layer-list>