Skip to content Skip to sidebar Skip to footer

Multi Color Stroke Image With Xml

Does it possible to create multi-color stroke with the help of XML? I want to create exact view attached here. Thanks

Solution 1:

You could use a trick by creating a drawable shape with gradient and make it a parent's background... something like this:

gradient_stroke.xml (in res/drawable):

<?xml version="1.0" encoding="utf-8"?><selectorxmlns:android="http://schemas.android.com/apk/res/android"><item><shapeandroid:shape="rectangle" ><gradientandroid:angle="180"android:startColor="#fff96200"android:centerColor="#fffff60f"android:endColor="#fff96200"android:centerX="50%"

                     ></gradient><cornersandroid:radius="5dp"></corners></shape></item>

your_view.xml:

<?xml version="1.0" encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical"android:layout_width="wrap_content"android:padding="2dp"android:background="@drawable/gradient_stroke"android:layout_height="wrap_content"><Buttonandroid:text="Submit"android:layout_width="wrap_content"android:layout_height="wrap_content"android:background="@color/green"android:id="@+id/button"/></LinearLayout>

Just an idea - play around with it to get desired values...

Post a Comment for "Multi Color Stroke Image With Xml"