Forums Register Login

handle orientation changes programatically

+Pie Number of slices to send: Send
Hello,

I have an app in which I have to handle orientation change myself rather than the system handling it,

here's the psuedocode

if(orientation==landscape)

rotate view by 90 degrees

else

keep the original view

can someone explain me how to handle it? I have checked many solutions over the net but i cant find one that fits this requirement...

Thanks
+Pie Number of slices to send: Send
Why do you need to handle the rotation yourself, and are you sure you need to? As you said, you checked other solutions and they don't fit your requirements. So perhaps you need to tell us your requirements, what you have tried, and why they didn't work so we don't re-hash the same old discussions. Make sure you have read the Android Developer Network article on this (http://developer.android.com/guide/topics/resources/runtime-changes.html) to see what it suggests - it has two examples on how it should be done.
+Pie Number of slices to send: Send
 

Steve Luke wrote:Why do you need to handle the rotation yourself, and are you sure you need to? As you said, you checked other solutions and they don't fit your requirements. So perhaps you need to tell us your requirements, what you have tried, and why they didn't work so we don't re-hash the same old discussions. Make sure you have read the Android Developer Network article on this (http://developer.android.com/guide/topics/resources/runtime-changes.html) to see what it suggests - it has two examples on how it should be done.



Hey Steve,

thanks ,I tried that link which you gave and I tried the second example but thats not the requirement.

Basically I have a camera application where, on rotating the phone from portrait to landscape, I just want to rotate one particular menu and not the whole parent view(and activity itself)

I checked for handling runtime orientation changes on google, and almost all of them point to the example which you gave. I also tried this code out...





AS shown, the above code works in rotating my menu by 90 degrees when the phone is in landscape while keeping other layouts in same mode, but the obvious problem is when I turn it back to portrait mode , its still tilted and I am confused in finding a way to rotate it back to its original position.

Cant I poll the value of the angle(90,180,etc) of the phone and rotate my menu?

Thanks,
Jeet
Rototillers convert rich soil into dirt. Please note that this tiny ad is not a rototiller:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1114 times.
Similar Threads
How get screenOrientation in activity?
Screen Orientation
Localization Of Desktop Icons For An Application
Application crashes
when i change android:orientation to horizontal it shows blank screen
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 05:20:08.