Reputation: 6451
I want to create layout out with rounded rectangle border with gradient filling color so I used the following selector
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<gradient
android:angle="90"
android:startColor="#FFFF0000"
android:endColor="#FF00FF00"
android:type="linear" />
<padding android:left="7dp" android:top="7dp"
android:right="7dp" android:bottom="7dp" />
<corners android:radius="4dp" />
</shape>
</item>
</selector>
and the layout look like this
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" android:background="@drawable/buttonsborder">
</LinearLayout>
but it doesn't fill all the sc reen only the controls I put on the layout , any idea how to make the selector fill the whole layout even if there's no controls
Upvotes: 1
Views: 112
Reputation: 1765
Hi use this xml for rounded rectangle borders and then set it in android:background
<
?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<gradient
android:endColor="#ffffff"
android:startColor="#ffffff"
android:angle="270" />
<stroke
android:width="0.5dp"
android:color="#808080" />
<corners
android:radius="10dp" />
<padding
android:top="10dp"
android:bottom="10dp"
android:left="10dp" />
</shape>
</item>
</selector>
Upvotes: 0
Reputation: 401
plz
use this in an xml
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<gradient
android:angle="225"
android:endColor="#FF0E2E57"
android:paddingLeft="20dip"
android:startColor="#FF0E2E57" />
<corners
android:bottomLeftRadius="40dp"
android:bottomRightRadius="40dp"
android:paddingLeft="20dip"
android:topLeftRadius="40dp"
android:topRightRadius="40dp"/>
and use this as your background. in layout
Upvotes: 1