Dim btn As Button
btn.Initialize("btn")
Dim P As Phone
If P.SdkVersion < 21 Then
'Android version < 5.0 Lollipop -> StateListDrawable
Dim PressedCD As ColorDrawable
PressedCD.Initialize(Colors.Blue, 0)
Dim DefaultCD As ColorDrawable
DefaultCD.Initialize(Colors.Gray, 0)
Dim bStateList As StateListDrawable
bStateList.Initialize
bStateList.AddState(bStateList.State_Pressed, PressedCD)
bStateList.AddCatchAllState(DefaultCD)
btn.Background = bStateList
Else
'Android version >= 5.0 Lollipop -> RippleDrawable
Dim bRipple As RippleDrawable
bRipple.Initialize(Colors.Gray, Colors.Blue)
btn.Background = bRipple.Drawable
End If
btn.TextColor = Colors.White
btn.Text = "Styled button"
Activity.AddView(btn, 0, 0, 50%x, 10%y)