when using android NDK NativeWindow to display image, how to lock orientation?
In android NDK, when use NativeWindow to display image, how to lock the orientation? Basically, when the phone rotate, I want the image relatively still to the phone. (See the illustration below, in case I’m not clear).
_____
| ^ |
| o |
|____|
_______
| < o |
|______|
I followed the sample program native plasma, and used the ANativeWindow_Buffer. My image resolution is 480x800, the native window’s resolution is also 480x800 if I hold the phone in portrait mode. However if I hold the phone in landscape mode, the native window size becomes 800x480, and my displayed image mess up unless I change how I fill the buffer. I wonder if there is a way to set the native window buffer size always to 480x800, and prevent it change when the phone rotates.
I see in the ANativeWindow API, there is a function, ANativeWindow_setBuffersGeometry I tried to use it to set the buffer geometry to 480 by 800, but it 开发者_StackOverflowdid not have any effect.
Please help. Thanks.
You should still be able to handle this in your Java side manifest, I believe...
in the activity tag, add
android:screenOrientation="portrait"
精彩评论