06-05-2012 05:57 AM
Hi, to all)
I need redraw my interphace after device rotation...
in myScreen i have a method
public LoginScreen()
{
scaleKoof = Display.getWidth()/320.0f;
// Create interface elements
}
If i coluld call this after rotation again all might be good! how i can do it?
scaleRotation - scale all images in my interpace...
Solved! Go to Solution.
06-05-2012 07:18 AM
01-21-2013 04:29 AM
I'm trying to do the same, but the dimensions returned by Display.getWidth or Display.getHeight, or even the value returned by Display.getOrientation do not change at all. I even tried using an invokeLater 1.5 secs after the method is called and still is returning the old values. This is the overriding method in my MainScreen class:
public void sublayout(int width, int height){
super.sublayout(width,height); //Tried calling this in the last line as well with identical result.
System.out.println(">>>>>>>>> Display.getWidth(before): " + Display.getWidth());
System.out.println(">>>>>>>>> Display.getOrientation(before): " + Display.getOrientation());
UiApplication.getUiApplication().invokeLater(new Runnable(){
public void run() {
System.out.println(">>>>>>>>> Display.getWidth(later): " + Display.getWidth());
System.out.println(">>>>>>>>> Display.getOrientation(later): " + Display.getOrientation());
}
}, 1000, false);
}
I need to stick to 4.5 OS, so I can't even lock the screen in one direction because I'll need to compile for 4.7. What other way of detecting screen dimensions are there other than the Display class? Is there a trick or something I'm doing wrong or missing?
Why are the Display methods still returning old values????
01-21-2013 05:33 AM
I thin arkadyz has noted this and suggested that you should focus on using the dimensions that are given to you in sublayout. For example, if you have a VFM, then the width is normally the full width of the device. So you can save the value as it was last time you did it, and if it changes rework your assets to match.
In this case, can you confirm that Display.getWidth() in sublayout is the same after a rotation as it was when your first laid out. Retain the value last used and see if it has changed.
BTW I believe that sublayout will get called when the virtual keyboard appears. In this case the height changes. I suggest just comparing the width to detect tilts so as you are not confused by height changes.
01-21-2013 05:48 AM
Yes, that was how I was trying to do it. But neither the arguments or the Display values change. I've read other posts suggesting that the API only updates the Display values after calling sublayout, so I tried with invokeLater. Unfortunately, even launching the runnable 2 seconds after the sublayout callback is not enough. Looks like these values are cached for a given screen.
Then I came to this post
There you suggested to check the values in a new screen pushed just for this purpose. That made me think that maybe the API is caching the values in a per-screen basis. But again it is not working for me.
I'm getting out of ideas.
01-21-2013 06:47 AM
I have not had this sort of issue. Can you tell me what OS you are developing on and what you are testing with. Perhaps a sample screen to demonstrate the problem too? That would make it easier for everyone to test.
01-21-2013 07:00 AM
01-21-2013 07:35 AM
simon_hain wrote:
and maybe move the discussion into a new thread instead of performing thread necromancy on somebody elses solved one.
Ok, I'll do as you say. But I disagree in the "somebody else's question" part. I think questions belong to the development community as a whole, and the fact that is solved is of little importance to me, as I'm having exactly the same issue. Posted here my case since Google's first result for my search was this, and I thought posting exactly the same question again would be frowned upon.