GradientDrawable

cnicolapc

Active Member
Licensed User
Longtime User
Hi,
how can I set the background code via Gradientdrawable and colors of a panel?
Thanks in advance
Nicola
 

klaus

Expert
Licensed User
Longtime User
The code below shows it:
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim pnlTest As Panel
Dim gd1 As GradientDrawable
Dim cols1(2) As Int
End Sub

Sub Activity_Create(FirstTime As Boolean)
pnlTest.Initialize(
"")
Activity.AddView(pnlTest,
5dip,5dip,100%x-10dip,100%y-10dip)

cols1(
0) = Colors.Cyan
cols1(
1) = Colors.Red
gd1.Initialize(
"TOP_BOTTOM",cols1)
gd1.CornerRadius=
0
pnlTest.Background=gd1
' Activity.Background=gd1
End Sub

The Gradientdrawable could also be set to the Activity or other Views.

Best regards.
 
Upvote 0

vb1992

Well-Known Member
Licensed User
Longtime User
I am using google Chrome, I don't see the code in post #2, I just see HTML tags

B4X:
Sub Globals 

Dim pnlTest As Panel 
Dim gd1 As GradientDrawable
 Dim cols1(2) As Int 

End Sub 

Sub Activity_Create(FirstTime As Boolean) 

pnlTest.Initialize("") 
Activity.AddView(pnlTest,5dip,5dip,100%x-10dip,100%y-10dip) 
cols1(0) = Colors.Cyan 
cols1(1) = Colors.Red 
gd1.Initialize("TOP_BOTTOM",cols1) 
gd1.CornerRadius=0
 pnlTest.Background=gd1 
' Activity.Background=gd1 
End Sub
 
Last edited:
Upvote 0
Top