gpt4 book ai didi

Android ScreenOrientation 行为

转载 作者:搜寻专家 更新时间:2023-11-01 07:55:23 25 4
gpt4 key购买 nike

我有一个 Activity ,我想始终保持纵向布局。我在 list 文件中获得了这些设置:

<activity android:name="Main"
android:launchMode="singleInstance"
android:label="@string/app_name" android:screenOrientation="portrait" android:configChanges="keyboardHidden|orientation" android:windowSoftInputMode="stateAlwaysHidden|adjustNothing">

如果我将设备翻转到侧面,此设置会使 Activity 仅将纵向布局加载到侧面。我希望布局保持在纵向位置,仅此而已,即使这意味着在将设备切换 90 度时在侧面查看布局。

最佳答案

从Android 3.2开始,还需要在configChanges中添加screenSize

android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation|screenSize"

来自 handling runtime changes 的开发人员文档

Caution: Beginning with Android 3.2 (API level 13), the "screen size" also changes when the device switches between portrait and landscape orientation.

关于Android ScreenOrientation 行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28480021/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com