Android Question Change label text background color

FERNANDO SILVEIRA

Active Member
Licensed User
Hello Guys,

I'm creating an array of labels by code and, as far as I could see, the text background property (among others) is not available by code.

Is that true? :(
In this specific case each label.text will have a single letter (ie, A B C D ... Z) but the background color is important.:)
Is there an alternate solution for that? Otherwise I wont accomplish the desired result.

B4X:
    wLeft = 10dip
    For i = 0 To wWordShuffled.Length - 1
        lblLetter(i).Initialize("lblLetter")
        wLetter = wWordShuffled.SubString2(i, i+1)
        Log(wLetter)
        lblLetter(i).Text = wLetter
        lblLetter(i).TextColor = Colors.White
        lblLetter(i).TextSize = 50
        lblLetter(i).left = wLeft
        Activity.AddView(lblLetter(i), lblLetter(i).left, 200dip, 35dip, 80dip)
        wLeft = wLeft + 50dip
        GDetector(i).SetOnGestureListener(lblLetter(i), "Gesture"&i)
    Next

Regards,
Fernando
 

FERNANDO SILVEIRA

Active Member
Licensed User
But if you really want your labels to have some flair, you can use a label with border, something like this:
B4X:
Dim cd As ColorDrawable
    cd.Initialize2(Colors.Red,15dip,10dip,Colors.Yellow)
    Label1.Background=cd

Good point you addressed here. Borders and shadows are my next challenge.

Thanx.
 
Upvote 0
Top