Is there any way to define a top and bottom stroke for a gradient, or create a compound shape drawable?:
// option1:
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#f00"
android:endColor="#0f0"
/>
<stroke
top=1dip, yellow
bottom=1dip, purple
/>
</shape>
// option2
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<shape
android:shape="rectangle"
height=1dip, color=yellow />
<gradient
android:startColor="#f00"
android:endColor="#0f0"
/>
<shape
android:shape="rectangle"
height=1dip, color=purple />
</shape>
I don't think either are possible?
Thanks
I guess, it can be done by using layer-list.
Following is the res/drawable/layer_list_shape.xml
I have used hard-coded dimensions..
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape android:shape="rectangle">
<size android:width="150dp" android:height="6dp"/>
<solid android:color="#ff0" />
</shape>
</item>
<item android:top="6dp">
<shape android:shape="rectangle" >
<size android:width="150dp" android:height="50dp"/>
<gradient
android:endColor="#0f0"
android:startColor="#f00" />
</shape>
</item>
<item android:top="82dp">
<shape android:shape="rectangle" >
<size android:width="150dp" android:height="6dp"/>
<solid android:color="#ff0" />
</shape>
</item>
res/layout/main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/layer_example" />
</LinearLayout>
Hope this helps..
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