[英]Need to create background with rounded corners
I want to create background with rounded corners, but inside should be transparent and outside should be white.我想用圆角创建背景,但里面应该是透明的,外面应该是白色的。
Its background for camera view but I cant combine those shapes.它用于相机视图的背景,但我无法组合这些形状。
Issue is that I cant combine rectangle with rounded corners and solid block shape.问题是我不能将矩形与圆角和实心块相结合。
rounded corner xml圆角 xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<stroke android:width="4dp" android:color="@color/white" />
<corners
android:bottomRightRadius="@dimen/corner_radius_2"
android:bottomLeftRadius="@dimen/corner_radius_2"
android:topLeftRadius="@dimen/corner_radius_2"
android:topRightRadius="@dimen/corner_radius_2"/>
<solid android:color="@color/transparent" />
</shape>
outer background xml外背景 xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/white" />
</shape>
final background:最终背景:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="@drawable/rounded_corner_background" />
<item android:drawable="@drawable/outer_background" />
</layer-list>
Expectation:期待:
Hope this works希望这有效
<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:left="6dp" android:right="6dp"> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <stroke android:width="20dp" android:color="#ffffff" /> </shape> </item> <item android:bottom="10dp" android:left="20dp" android:right="20dp" android:top="10dp"> <shape android:shape="rectangle"> <stroke android:width="10dp"/> <corners android:radius="10dp" /> <solid android:color="@android:color/transparent" /> </shape> </item> </layer-list>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.