0

I know how to get the dimensions of the screen onCreate. I was making a runnable which will allow me to get the dimensions inside of that.

The thing is that when i rotate my device, it doesnt seem to properly return the dimensions.

I was thinking to do it onConfigurationChanged() as that seems to firre when i rotate my device. I was trying to do the following but i dont think it was giving valid data.

Rect r = new Rect();
Window win = getWindow();
win,getDecorView().getWindowVisibleDisplayFrame(r);
int height = r.height();
int width = r.width();

but it seems that they arent correct. I was trying to move a created item around the screen, and it doesnt go to the edges of the screen. I dont think it has anything to do with my drag function.

I feel the dimensions are incorrect.

How is this done? Am i on the right path?

Fallenreaper
  • 10,222
  • 12
  • 66
  • 129
  • Have you tried this? [http://stackoverflow.com/a/1016941/1729781][1] [1]: http://stackoverflow.com/a/1016941/1729781 – Agata Oct 08 '12 at 19:37
  • yea, it was giving me dimensions of a full screen. As of right now, what i did was relaunch the activity to bypass the issue at hand and it works, but it isnt, IMO the best way to handle it... granted the stuff that looks like would work, is for the newer API's... and i am using API7 or earlier at the moment. – Fallenreaper Oct 08 '12 at 19:39

1 Answers1

0

The workaround i had created was that onConfigurationChange() I created a bundle with attributes and then recalled onCreate(). Essentially this would recreate in the new orientation.

This was what i did to get around this issue at hand, and it made it so the layout is rerendered.

Bundle b = new Bundle();
b.putString("test","data here");
onCreate(b);
Fallenreaper
  • 10,222
  • 12
  • 66
  • 129