Is there a way how to lock the screen orientation but still be able to listen for device orientation changes? My UI consists of an ImageView
and few buttons
at the bottom. The application screen orientation should be locked but the images on the buttons should change when the device orientation changes.
Thanks in advance.
Yes, there is a way. In the AndroidManifest.xml, where your activity is declared, you need to add another property configChanges as following.
<activity android:name="YourActivity"
android:configChanges="orientation|screenSize" />
This means your activity will handle orientation and currently available size changes by itself. Then you have to override onConfigurationChanged() method in your Activity and change images there.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.