Android Question Highlight a label

Sanxion

Active Member
Licensed User
Longtime User
Guys

Does anybody know of a method to 'highlight' a label for the moment that it is clicked on only?

Thank-you in advance!
 

inakigarm

Well-Known Member
Licensed User
Longtime User
Not sure if this is what you're searching (when click on label, the border is drawed)

B4X:
Sub Label1_Click
    Dim cd As ColorDrawable
    cd.Initialize2(Colors.Transparent,2,2,Colors.Black)
    Label1.Background=cd
End Sub

The drawback is to return to a non-click state (you'd have to code when clicking the other views of the activity)
 
Upvote 0

canalrun

Well-Known Member
Licensed User
Longtime User
For the label I am pretty sure you can achieve highlighting when pressed by using an on-touch listener. There are examples for setting on-touch for a view in the forum. I have never done this, but I think it should be possible. On down change the text color to the highlight color. On up change the text back.

Also, I've never done this, but if you define statelist bitmaps for a button, I will bet if you make a portion of the bitmap transparent you could achieve transparency. Again I have never done this, but it could be an interesting effect.

I'm sure I will be corrected, if wrong.

Barry.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Can buttons have a transparent background in the same way that a label can?
Sure, no problem!
For the Background you must set StateListDrawable and for the Enabled state set a ColorDrawable with a transparent color and for the Pressed state set a ColorDrawable with a border and a transparent color.
This can be done in the Designer or in the code.
 
Upvote 0
Top