GradientDrawable not provided

The argument Colors is an array so you can use more than 2 colors to create the gradient.

Code: Copy
Dim Gradient1 As GradientDrawable
Dim Clrs(3) As Int
Clrs(0) = Colors.Black
Clrs(1) = Colors.White
Clrs(2) = Colors.Black
Gradient1.Initialize("TOP_BOTTOM", Clrs)
 
Upvote 0
The argument Colors is an array so you can use more than 2 colors to create the gradient.

Code: Copy
Dim Gradient1 As GradientDrawable
Dim Clrs(3) As Int
Clrs(0) = Colors.Black
Clrs(1) = Colors.White
Clrs(2) = Colors.Black
Gradient1.Initialize("TOP_BOTTOM", Clrs)

Thanks, this is very interesting, unfortunately not fully resolve my problem. I need that the Gradient is directed from the center towards all directions.
 
Upvote 0
Upvote 0
Erel in another post has provided the answer. Thanks Erel.

Code: Copy
Sub Activity_Create(FirstTime As Boolean)
    Dim GD As GradientDrawable
    GD.Initialize("TOP_BOTTOM", Array As Int(Colors.White, Colors.Black))
    Activity.Background = GD
    SetRadialGradient(GD, Activity.Height/2)
End Sub

Sub SetRadialGradient(GD As GradientDrawable, radius As Float)
    Dim r As Reflector
    r.Target = GD
    r.RunMethod2("setGradientType", 1, "java.lang.int")
    r.RunMethod2("setGradientRadius", radius, "java.lang.float")
End Sub
 
Upvote 0
Attached you find a small demo program for GradientDrawables you can play with.
You can change :
- corner radius
- gradiend shape
- gradient type
- gradient orientation
- gradient radius
- gradient center

About Rectangle Gradient, if you expect a gradient with a rectangular shape (rectangles changing colors) this is not supported in Android.

Best regards.

EDIT: 2012.12.18
updated the zip file
 

Attachments

  • Demo.jpg
    Demo.jpg
    54.3 KB · Views: 677
  • GradientDrawable.zip
    GradientDrawable.zip
    9.5 KB · Views: 447
Last edited:
Upvote 0
Back
Top