Reputation: 2914
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 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 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:
Upvotes: 0
Views: 53
Reputation: 11
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>
Upvotes: 1