I'm trying to create an Android XML Drawable that I can use as the background for one of my LinearLayouts. I need the background to have an image, with the top left and top right corners rounded with a 10dp radius. I've been trying with the code below, but just can not seem to get it working. Is this possible? Any help is greatly appreciated!!
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<corners android:topLeftRadius="10dp"
android:topRightRadius="10dp">
</corners>
</shape>
</item>
<item>
<bitmap android:src="@drawable/bg_navbar_blur" />
</item>
Try using px instead of dp:
<corners android:topLeftRadius="10px"
android:topRightRadius="10px">
</corners>
EDIT:
This is the complete XML that I am using to round edges in one of my elements:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<solid android:color="#99000000" ></solid>
<corners android:radius="8px"></corners>
<stroke android:width="0dp" android:color="#A4C2E0"></stroke>
</shape>
EDIT 2:
I would try this. Put the image and it's layout (not rounded) in a new XML and place it in a drawable folder. Let's say it's named linearlayout_bg.xml... In your main layout, create a new LinearLayout and apply this following attribute:
android:background="@drawable/linearlayout_bg"
And then use your <corners
code. Maybe that'll work?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With