-4

NOTE : updated question !

i want to make gradiend as mentioned in the pic

pic

the centered gray is a line i want it to be merged with both right left

Solution tried

Android drawable with background and gradient on the left

i couldnt find more about custom drawable gradient how i need

 <shape android:shape="rectangle">
        <gradient
            android:angle="0"
            android:centerColor="@color/white"
            android:endColor="@color/gray"
            android:startColor="@color/gray"
            android:type="linear"
            />
 </shape>

i have these two images and want to make them with drawable ..

thanks in advance ..

PS : I have also tried the answer i got against my question but i think this gradient isnt possible i have been waiting since 3 months for solution.

Atif Afridi
  • 133
  • 1
  • 10

3 Answers3

1

Try to use type as radial :

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle"
    android:useLevel="false">
    <size
        android:width="48dip"
        android:height="48dip" />

    <gradient
        android:centerColor="@android:color/white"
        android:centerY="0.5"
        android:gradientRadius="180"
        android:type="radial"
        android:useLevel="false" />
</shape>
khetanrajesh
  • 300
  • 3
  • 13
  • height n weight reduce the size only i have tried this – Atif Afridi Aug 10 '17 at 11:50
  • @AtifAfridi Not height and weight , try to use android:type="radial" . Just paste the code above in your studio and see the preview . I guess that is what you want . – khetanrajesh Aug 10 '17 at 11:56
  • i tried the same .. but not what i want .. i want all in vertical direction .. right n left would be gray n center would b white but merged with the right/left gray color but its making white line vertically – Atif Afridi Aug 10 '17 at 12:16
0

try this and change color what you want

android:background:"@drawable/color_grad"

color_grad.xml
 <shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
    android:centerColor="#FAFAFA"
    android:endColor="#C7C7C7"
    android:startColor="#C7C7C7"
    android:type="linear"
    android:angle="270"/>
<corners android:radius="0dp" />

MurugananthamS
  • 2,395
  • 4
  • 20
  • 49
0
android:background="@drawable/gradient"   

 <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="rectangle">
        <gradient
            android:startColor="#C3C3C3"
            android:endColor="#00000000"
            android:angle="45"/>    
    </shape>