Sunday, July 8, 2012

[android-developers] Orientation is Portrait but width/height is reversed?

I found an interesting issue in HTC Jetstream tablet running Android 3.1. I am not sure whether it is a bug or not but seems like it is.

I have a drawing app where will work only in Portrait but I keep having issue in this tablet (but works fine elsewhere). The orientation is set to portrait in manifest file, and the tablet is set to not auto-rotate with default of landscape (which might be causing the issue).

So when the app started, it is rotated to Portrait, and the codes below will check for the width/height:

Display display = getWindowManager().getDefaultDisplay();

width = display.getWidth();

height = display.getHeight();


The problem is: most of the time I got width = 1280 and height = 800 (which is landscape) but if I check for orientation (getResources().getConfiguration().orientation) I got portrait!

This seriously screwed up the UI when the app runs in the tablet, so my current "fix" is to check for width > height, if yes, then swap the width/height.

Does anybody seen this issue elsewhere or have a better solution? Thanks!

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment