android - Create a custom gradient with 2 shapes -


i want create gradient background in android. i've used angrytools.com generate these 2 shapes. not sure how implement them.

<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <gradient  android:type="linear" android:centerx="100%"  android:startcolor="#7f000000"  android:centercolor="#ffffffff"  android:endcolor="#ffffffff"  android:angle="90"/> </shape>  ------------------------------------------------- <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <gradient  android:type="radial" android:centerx="50%"  android:centery="50%"  android:startcolor="#7f000000"  android:centercolor="#ffffffff"  android:endcolor="#ffffffff"  android:gradientradius="100"/> </shape> 

try use layer-list create yourfile.xml in drawable folder that

<item>    <layer-list>     <item>             <shape xmlns:android="http://schemas.android.com/apk/res/android"      android:shape="rectangle" >            <gradient              android:type="linear"             android:startcolor="#7f000000"              android:centercolor="#ffffffff"              android:endcolor="#ffffffff"              android:angle="90"/>             </shape>       </item>       <item>             <shape xmlns:android="http://schemas.android.com/apk/res/android"    android:shape="rectangle" >             <gradient              android:type="radial"             android:centerx="0.5"              android:centery="0.5"              android:startcolor="#7f000000"              android:centercolor="#ffffffff"              android:endcolor="#ffffffff"              android:gradientradius="100"/>             </shape>       </item>    </layer-list> </item> 

and use android:background="@drawable/yourfile.xml"


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -