I need to create a round corner border, where border with gradient.enter link description here is working.But My page is using a image as background which is also with gradient. I need to show background image from middle of the filed. I want to create just like below image:
Asked
Active
Viewed 7,835 times
16
1 Answers
2
round_background.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/transparent" />
<gradient
android:startColor="#374533"
android:centerColor="#432727"
android:endColor="#222430"
android:angle="135"/>
<corners android:radius="10dp" />
</shape>
round_border.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:startColor="#efe301"
android:centerColor="#7dc17b"
android:endColor="#01dae6"
android:angle="180"/>
<corners android:radius="10dp" />
result_drawable.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/round_border"/>
<item android:drawable="@drawable/round_background" />
</layer-list>
Here, you can set android:width="4dp" in round_background.xml to set size of your border. use result result_drawable.xml where you want.. Enjoy. :}

jainish champaneria
- 155
- 1
- 4
-
I have background also with gradient color, so how to match with background color? – Suman Feb 10 '17 at 08:10
-
Worked for me for custom tab layout – Ganesh Pokale May 14 '19 at 08:01
-
2that is not desired result, the inner background is not really transparent – Arda Kaplan Jun 02 '20 at 14:58
-
You would need a different round_background.xml for each position on the background.. That does not make sense.. – Tobi Dec 05 '20 at 10:55