Label fade on click

Roger Garstang

Well-Known Member
Licensed User
Longtime User
Label fading on click and transitions

I have a weird thing happening in some labels I can't figure out. On my screen/activity I have various labels. Most labels are just labels. Some labels are buttons drawn with a 9 Patch with state changes. Recently I also made some labels that behave like a spinner/combobox and show an InputList when clicked. They also have a 9 Patch to draw them like a combo box.

All of them have black text- The true labels and the button labels I set with Colors.Black and the combobox variation I don't set...it draws black, so I'd assume it is defaulted to Black. Whenever any InputList, Msgbox, screen change or fade occurs though the text of the combobox variety turns gray/grey like it is disabled. Is the default color of a view's text some special color that behaves this way?
 
Last edited:

mc73

Well-Known Member
Licensed User
Longtime User
Talking about the period that the modal views are on? If so, I think it's natural that the other views turn disabled. If you mean that the views remain 'grayed' after closing a modal, then sure it's weird, I have no answer.
 
Upvote 0

Roger Garstang

Well-Known Member
Licensed User
Longtime User
Talking about the period that the modal views are on? If so, I think it's natural that the other views turn disabled. If you mean that the views remain 'grayed' after closing a modal, then sure it's weird, I have no answer.

By period do you mean panel? That black fade is fine, this is the actual text turning grey. All other view's text is black and they are grey. I can see it though the modal blackness fade and during a screen transition. After the modal fade or screen transition they go back to black like the others.

At first I thought it was the text changing color due to clicking...I have never seen this on my devices, but have seen some weird code to change the states here as well as it being added to the new code snips guide in the user manuals just released. (Plus the buttons are also labels and didn't change color when being clicked) Then I noticed when I had more than one view on screen I could see that they all changed.

I fixed it by setting it to a color like the others...I just thought it was odd that the default label color did this.
 
Last edited:
Upvote 0

Roger Garstang

Well-Known Member
Licensed User
Longtime User
Tested this further and found the cause for two problems:

1. I never saw the color change when pressing my labels because I don't like the default color which is Colors.ARGB(255, 190, 190, 190) and doesn't match any named colors and doesn't match the Windows LightGray/LightGrey definition either which is 192,192,192. I always give my labels a black textcolor and usually bold which appears to override this behavior when giving them textcolor.

2. The reason for my default color appearing black was because of this:

B4X:
Sub SetMarquee(control As Label)
Dim ref As Reflector

   ref.Target = control
   ref.RunMethod2("setLines", 1, "java.lang.int")
   ref.RunMethod2("setHorizontallyScrolling", True, "java.lang.boolean")
   ref.RunMethod2("setEllipsize", "MARQUEE", "android.text.TextUtils$TruncateAt")
   ref.RunMethod2("setMarqueeRepeatLimit", -1, "java.lang.int")
   ref.RunMethod2("setSelected", True, "java.lang.boolean")
End Sub

I do something like this on all my labels just to make sure even if I don't size them properly the user can still read them. I found the code here and from what I gather the last setSelected line is needed to start the animation...and also what made the label think it was clicked to show in black at the start. Screen transitions and modal dialogs must shift the focus so they are not selected anymore and they turn gray/grey until the activity is the foreground again.

On a side note...It would be cool to have labels default to Black with maybe a Blue as the clicked/selected color, then I'd actually use this feature. In my View Manager class I use Labels as links to give Focus to a linked Textbox, so I may have to look at that function for setting the colors again and see if I can get it and the Marquee to play nice together.
 
Upvote 0
Top