Linear gradient with small color transition

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Linear gradient with small color transition

Postby sanyiii » Tue Feb 16, 2010 5:25 pm

Hi everybody,

I have a simple problem: i want to create a gradient like in the attachment.
I can do this, if i define a lot of colors in the GradientDrawable object, but i think it's not the best solution.
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. final int[] colors = new int[10];
  3.  
  4.                 colors[0] = Color.BLACK;
  5.  
  6.                 colors[1] = Color.BLACK;
  7.  
  8.                 colors[2] = Color.BLACK;
  9.  
  10.                 colors[3] = Color.BLACK;
  11.  
  12.                 colors[4] = Color.BLACK;
  13.  
  14.                 colors[5] = Color.DKGRAY;
  15.  
  16.                 colors[6] = Color.DKGRAY;
  17.  
  18.                 colors[7] = Color.DKGRAY;
  19.  
  20.                 colors[8] = Color.DKGRAY;
  21.  
  22.                 colors[9] = Color.DKGRAY;
  23.  
  24.  
  25.  
  26.  
  27.  
  28. final GradientDrawable gradient = new GradientDrawable(Orientation.TOP_BOTTOM, colors);
  29.  
  30.  
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


How can i modify the size of the color transition (java and xml code is good for me as well)?

Thanks for the help!
Attachments
gradient.png
gradient.png (19.94 KiB) Viewed 136 times
sanyiii
Developer
Developer
 
Posts: 42
Joined: Wed Jun 10, 2009 9:58 am

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 5 guests