in my app i want to place a rounded corner background in an activity. The image i want is as follows
The background image of my app is to be a white screen and inside my rounded corner background i need white spaces. So to identify corners of the rounded background i need to give a black color for it. But my image appears as follows.
Following is my code for rounded background
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#ffffff" />
<stroke android:width="3dp" color="#ff000000" />
<corners android:radius="15dp" android:color="#ababab" />
<padding android:left="10dp" android:top="10dp" android:right="10dp" android:bottom="10dp" />
</shape>
How to get the black color as my corner color
Here's an example that does almost exactly what you request:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient android:startColor="#FFFFFFFF" android:endColor="#A4A4A4"
android:angle="270" />
<corners android:radius="5dp" />
<stroke android:color="#4B4B4B" android:width="1dp" />
</shape>
From the great tutorial at: http://blog.stylingandroid.com/
It's a bit hard to understand what you actually want to achieve, but assuming you've added
<corners ... android:color="#ababab" />
You want to make you cornewr to have color #ababab
.
First file named shape.xml
should have the xml from your answer:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#ffffff" />
<stroke android:width="3dp" color="#ff000000" />
<corners android:radius="15dp" />
<padding android:left="10dp" android:top="10dp" android:right="10dp" android:bottom="10dp" />
</shape>
Note how I removed android:color="#ababab"
from your example in <corners>
tag.
Second file named solid.xml
should have next xml:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#ababab" />
</shape>
Finally, the file named background.xml
:
<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="@drawable/solid" />
<item android:drawable="@drawable/shape" />
</layer-list>
You should use @drawable/background
for background in your activity.
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