I'm trying to achieve what amounts to effectively 2 strokes on a rectangle in a <shape>
element in an android drawable xml. A dark green outer line and a light green inner line, with a gradient fill in the center of it all. My code currently looks like this:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<stroke android:width="3px" android:color="#477135" />
</shape>
</item>
<item >
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient android:startColor="#81c557" android:endColor="#539942"
android:angle="270" />
<stroke android:width="1px" android:color="#a8d78a" />
</shape>
</item>
I have tried applying android:top="3px" android:bottom="3px" to the 2nd item element, but when i add the right & left attributes, the entire thing doesn't render. Note, this is all done within a ListView
well, i believe i solved this with a work around. it aint pretty but it works. What i did was set an ImageView to have a background color set to the outer line color, gave it a padding of 1dip, then set the src of the ImageView to the drawable and i achieve the effect i was looking for. That said, i'd much prefer to be able to do this all within the layer-list...
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