android - Linear Gradient CenterX -
i trying make transparent gradient background button, this:
(the start color not grey transparent)
but getting this: (where white portion narrow)
this gradient.xml:
<!-- here centerx not work --> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <gradient android:centerx="30%" android:startcolor="@android:color/transparent" android:endcolor="@android:color/white"/> </shape>
i have tried adding centercolor
, transparent area turns grey!
<!-- here startcolor turns greyish --> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <gradient android:centercolor="@android:color/white" android:centerx="30%" android:endcolor="@android:color/white" android:startcolor="@android:color/transparent" /> </shape>
thanks in advance!
if need gradient moved left side of drawable, try this:
<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:left="100dp"> <color android:color="@android:color/white"/> </item> <item android:width="100dp"> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <gradient android:centerx="30%" android:endcolor="@android:color/white" android:startcolor="@android:color/transparent"/> </shape> </item> </layer-list>
this layer consist of 2 rectangles:
- white rectangle moved right 30dp
- gradient rectangle, width 30dp
Comments
Post a Comment