Dark buttons on Atrix

kickaha

Well-Known Member
Licensed User
Longtime User
I am using a Motorola Atrix (Android version 2.2.2), and buttons created with the designer are much darker than on other devices.

I notice that the default text colour for buttons within the OS seems to be white, whereas B4A has black. Attached is a screenshot of SCalculator running on a 2.1 device on the left, and on the Atrix on the right, so you can see what I mean.

Is this a problem anyone else is seeing? and is there a fix or workround?
 

Attachments

  • scalc.jpg
    scalc.jpg
    12 KB · Views: 549
For further info, I have discovered that Spinner controls are handled correctly - that is the text is black on the 2.1 device and white on the 2.2.2 device.

What is the difference between the button text settings and the spinner text settings?
 
Upvote 0
As a further test, I ran the Dialogs demo, and the number dialog displays the "+" and "-" buttons differently (see below). Does anyone know how these buttons are coded, and what the difference is between them?
 

Attachments

  • number21.jpg
    number21.jpg
    13.5 KB · Views: 520
  • number222.png
    number222.png
    13.4 KB · Views: 471
Upvote 0
Maybe the default theme on the Atrix is non-standard. It seems I have been inconsistent in setting the + and not the - button colors. You can't see the difference on either of my devices so I didn't pick that up. I changed the number buttons to match the + and - buttons - maybe I should leave them all "au naturel" in the next version
Code: Copy
   btn0.setText("+");
   btn0.setTextColor(Colors.DarkGray);
   btn0.setTextSize(32);
Numbers
Code: Copy
   btn0.setBackgroundColor(Colors.LightGray);
   btn0.setTextColor(Colors.DarkGray);
   btn0.setText(Integer.toString(numbers[i]));
   btn0.setTextSize(32);
- buttons
Code: Copy
   btn0.setText("-");
   btn0.setTextSize(32);
 
Upvote 0
Erel, is the button text colour explicitly set when loaded from a layout?

If I add a button in the code the text colour on the Atrix is white, same button added via a layout the text colour is dark grey.
 
Upvote 0
Yes, all the properties that can be specified in the designer are actually assigned to a view when the activity is built.

Is it possible to tell the designer NOT to set the text colour, or to set it to the device default, as if it is not set when a button is added in the code it is handled correctly without having to specify a colour.
 
Upvote 0
OK, as I cannot do it that way, I have found a work-round, and am posting it in case anyone else has the same issue:

First I defined a variable ButtonColour as Int in the main Process_Globals.
Then, in the main Activity_Create I added
Code: Copy
Dim Test As Button 
test.Initialize (test)
ButtonColour = test.TextColor
test.RemoveView
before I loaded a layout.

Now, each time I load a layout I call
Code: Copy
General.ColourButtons (Activity )
or
Code: Copy
General.ColourButtonsP (PanelName )
depending if the layout was added to an activity or a panel.

I then put the following subs in my General module:
Code: Copy
Sub ColourButtons (Value As Activity)
   Dim DummyB As Button 
   Dim DummyP As Panel

   For i = 0 To Value.NumberOfViews - 1
      If Value.GetView(i) Is Button Then 
         DummyB = Value.GetView (i)
         DummyB.TextColor  = main.ButtonColour 
        End If 
      
      If Value.GetView (i) Is Panel Then
         DummyP = Value.GetView (i)
         For l = 0 To DummyP.NumberOfViews - 1
            If DummyP.GetView (l) Is Button Then
               DummyB = DummyP.GetView (l)
               DummyB.TextColor  = main.ButtonColour
            End If
         Next
      End If
      
   Next 
End Sub
Sub ColourButtonsP (Value As Panel)
   Dim DummyB As Button 
   Dim DummyP As Panel

   For i = 0 To Value.NumberOfViews - 1
      If Value.GetView(i) Is Button Then 
         DummyB = Value.GetView (i)
         DummyB.TextColor  = main.ButtonColour 
        End If 
      
      If Value.GetView (i) Is Panel Then
         DummyP = Value.GetView (i)
         For l = 0 To DummyP.NumberOfViews - 1
            If DummyP.GetView (l) Is Button Then
               DummyB = DummyP.GetView (l)
               DummyB.TextColor  = main.ButtonColour
            End If
         Next
      End If
      
   Next 
End Sub
and it all works perfectly.
The above two routines are exactly the same as I could not figure out how to deal with activities and panels at the same time (anyone any ideas):sign0085:.

All that is left is the "+" buttons in the dialogs, which is on agrahams list.
 
Upvote 0
The above two routines are exactly the same as I could not figure out how to deal with activities and panels at the same time (anyone any ideas)
You can copy all the views to a list and then handle the list views. This will allow you to use a single method. Don't worry about copying the views as only a reference is copied.

Another thing you can do is to call this method recursively when you find a panel. This way it will support and structure of panels within panels.
 
Upvote 0
You can copy all the views to a list and then handle the list views. This will allow you to use a single method. Don't worry about copying the views as only a reference is copied.

Another thing you can do is to call this method recursively when you find a panel. This way it will support and structure of panels within panels.

:sign0161: Thanks Erel, don't know why I did not think of that!
 
Upvote 0
Being an Atrix user, I see the same issue... my question is...

Is it an Atrix problem or B4A since I don't see it with any other apps that I have loaded...

Thanks !

Gary M
 
Upvote 0
I want to appologize if it's just me being stupid.

I certainly read the thread and the workaround. Excellent work !

I read where "maybe" the Atrix uses a different default theme but I did not read the exact answer as to why Atrix/M8600 have dark buttons. :sign0013:

Just the OLD programmer in me just trying to understand.

Gary M
 
Upvote 0
Being an Atrix user, I see the same issue... my question is...

Is it an Atrix problem or B4A since I don't see it with any other apps that I have loaded...

Thanks !

Gary M

agraham's answer in post #6 indicates it is a function of B4A, as buttons added in designer are assigned an explicit colour, whereas adding via code the colour is the OS default unless changed.

It would be nice if the designer allowed the default to be used, and then I would not have to adapt the code based on the device.
 
Upvote 0
I did not read the exact answer as to why Atrix/M8600 have dark buttons.
I don't know why but they just are a different colour to the usual Android defaults.

As written earlier Views added in the designer have their properties explicitly set, those added programmatically adopt the defaults.
 
Upvote 0
Back
Top