D
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("1")
Dim canvas1 As Canvas
canvas1.Initialize(Button1)
Dim r As Rect
Dim btnRect As Rect
btnRect.Initialize(0, 0, Button1.Width, Button1.Height)
r.Initialize(btnRect.CenterX - 30dip, btnRect.CenterY - 30dip, _
btnRect.CenterX + 30dip, btnRect.CenterY + 30dip)
canvas1.DrawBitmap(LoadBitmap(File.DirAssets, "smiley.gif"), Null, r)
'additional code
Dim sld As StateListDrawable
sld.Initialize
Dim cd As ColorDrawable
cd.Initialize(Colors.Green, 5dip)
sld.AddState(sld.State_Pressed, cd)
sld.AddCatchAllState(button1.Background)
button1.Background = sld
End Sub
Thank you for the example but I would like to create a button like the Library fgGradientButtons. Isn't that possible with Basic4Android?Thank you for the example but I would like to create a button with the Library fgGradientButtons. Isn't that possible with Basic4Android?
Sub Process_Globals
End Sub
Sub Globals
Dim Button1 As Button
Dim r As Rect
Dim btnRect As Rect
Dim Gradient1 As GradientDrawable
Dim canvas1 As Canvas
Dim Clrs(2) As Int
Dim time As Timer
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("1")
canvas1.Initialize(Button1)
btnRect.Initialize(0, 0, Button1.Width, Button1.Height)
r.Initialize(btnRect.CenterX - 30dip, btnRect.CenterY - 30dip, _
btnRect.CenterX + 30dip, btnRect.CenterY + 30dip)
DrawButton(Colors.Green,Colors.Blue)
time.Initialize("time",100)
End Sub
Sub Button1_Click
DrawButton(Colors.Blue,Colors.Green)
time.Enabled=True
End Sub
Sub time_Tick
DrawButton(Colors.Green, Colors.Blue)
time.Enabled=False
End Sub
Sub DrawButton(col1 As Int, col2 As Int)
Clrs(1) = col1
Clrs(0) = col2
Gradient1.Initialize("TOP_BOTTOM", Clrs)
Canvas1.DrawDrawable(Gradient1, btnRect)
canvas1.DrawBitmap(LoadBitmap(File.DirAssets, "smiley.gif"), Null, r)
Activity.Invalidate
End Sub