android - Linear Gradient CenterX -


i trying make transparent gradient background button, this:

(the start color not grey transparent)

desired gradient

but getting this: (where white portion narrow)

enter image description here

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:

  1. white rectangle moved right 30dp
  2. gradient rectangle, width 30dp

Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -