in android, I want to define a shape
file in drawable
folder: myShape.xml
such as below:
<?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"/>
<corners android:radius="@dimen/corner"/>
<stroke
android:width="5dp"
android:color="@color/boder_endcall_color"/>
</shape>
And I want to create a gradient border in <stroke />
, but actually I don't know how! So anyone can give a example of creating shape
with gradient
color in stroke
?
Thanks!
Edit: I want gradient
the color from #F85C5C
(red) to #F68282
(reddish).
You best option is to use a nine-patch image which has the gradient already set to the desired colors(I don't see any easy way to do that gradient in a xml drawable).
For example, using your colors here is such a nine-patch(ignore my awful design skills):
Of course, for best results, you should have different nine-patch images for different resolutions(ldpi, hdpi etc)
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