开发者

Android - Changing screen orientation

开发者 https://www.devze.com 2023-04-03 14:12 出处:网络
Suppose that within an activity my initial screen orientation is landscape. In the开发者_如何学运维 same activity, I would like to add a button which changes the screen orientation from landscape to p

Suppose that within an activity my initial screen orientation is landscape. In the开发者_如何学运维 same activity, I would like to add a button which changes the screen orientation from landscape to portrait.

Is this possible in any way, or should I switch to a new activity ?

Thanks.


Use Activity.setRequestedOrientation() method


you can add new views to your layout, but first you need to detect the orientation change which is explained in the following link how it's done.

How to detect orientation change in layout in Android?

hope this helps

0

精彩评论

暂无评论...
验证码 换一张
取 消