Objects in a class appear distorted after Activity pause and resume

Mickster

Active Member
Licensed User
Longtime User
I made a numeric keypad object that consists mainly of buttons and panels.

When I launch the activity, the object is built and works totally fine. However, after pausing the activity by loading another, and then resuming the activity by returning to it, some of the objects inside the class appear distorted.

For instance, some of the buttons will have altered dimensions. They will regain their dimensions if you click them, but upon resuming they look weird. I managed to fix this issue by initializing the numeric pad class in the Activity_Resume routine, but I have no idea why this works.

Anyone know what I might be doing wrong?

I also have a button inside this numeric pad class that creates a panel and adds it to the activity. When the panel is added, the gradient on my activity appears to be reversed (the gradient is a white to a light grey, but upon generating this panel, the gradient changes to black/dark grey). After releasing the button (removing the panel), the gradient returns to normal.

Again, anyone have any ideas? I know these seem like two different issues and warrant two posts, but something tells me I'm being an idiot and overlooking something big that relates to two.

Thanks
 

klaus

Expert
Licensed User
Longtime User
The problem is that you set the same GradientDrawable to buttons of different size.
When the screen is updated the GradientDrawable keeps the dimensions of the last view, in your case a small button.
In the attached program I added another GradientDrawable for the small buttons.

1) Why do you use a panel + a label and not simply buttons with a StateListDrawable ?

2) Why do you use GradientDrawable instead of ColorDrawable, both colors are the same ?

3) The texts in some views are quite big ?

Best regards.
 

Attachments

  • Phenix Zip1.zip
    350.6 KB · Views: 209
Upvote 0

Mickster

Active Member
Licensed User
Longtime User
Thanks Klaus, that makes sense.

Do you have any idea about my second problem? They now seem to be caused by a different issue so perhaps I should start a different thread.

To answer your questions:

1. The combination of the label and panel is to provide a smaller 'button' (the label), with a larger surface area (the panel). We're dealing with heavy handed people and they're going to find our small buttons frustrating, but we need to save space. I know it's pretty weird.

2. The gradientdrawable was used because I was experimenting with different colours to find one that I liked. Initially they were gradients, but I have ended up with just solid colours. I didn't think it would make enough of a difference to warrant the effort of changing the type ahah.

3. Similar reasoning as my first answer. We have a very unusual end user and we need the UI elements and text to be as large and readable as possible. We need minimal text and any text has to be huge, otherwise the UI will look 'complicated' and our software will no longer be of interest.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
In my previous post I missed the second problem.

What button is adding a panel.
I couldn't reproduce it.
But anyway the problem must be similar.

If you use buttons with GradientDrawable or ColorDrawables their dimensions and also the text size would be the same as the labels and no need to handle the state !
That was the reason of my question.
With big texts I meant that some of them are even bigger than the view they are in.


Best regards.
 
Last edited:
Upvote 0

Mickster

Active Member
Licensed User
Longtime User
It is a panel inside the NavigationButtons class that calls a routine called 'createOverviewBox'. The routine creates a panel and places it on the activity. It causes the gradient of the activity to reverse.

Also, I just realised you were referring to a different set of panels with labels that represent buttons. I used these because I only just found out you can create statelistdrawables in code (!!!). I believed that the states of a button were controlled using the 'Button_Down' and 'Button_Up' routines. There a few graphical glitches with using these routines so I've always resorted to either creating my buttons in Designer or just using a panel and a touch event. Wow. What am I playing at!

:sign0104:
 
Upvote 0

Mickster

Active Member
Licensed User
Longtime User
I just updated my tablet to ICS and the issue went away. Pretty weird, but I can make sure that my end user is on ICS so no biggie.

Thanks for the help with the other thing, though.
 
Upvote 0
Top