gpt4 book ai didi

Android - ActionBar 未使用 onConfigurationChanged ( AppCompat ) 调整大小

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:03:45 25 4
gpt4 key购买 nike

在我的应用程序 list 中,我添加了 android:configChanges 以防止 Activity 在旋转时重新加载/重启

<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden|screenSize" >

它有效,但 supportActionBar(我正在使用 AppCompat)保留了他的高度和小字体。

ActionBar 应该纵向更大,横向更小,但它保持初始值:

  • 如果我从横屏开始,actionbar 在竖屏时保持纤细
  • 如果我从纵向开始,actionbar 在横向时会保持很大

删除 android:configChanges="orientation|keyboardHidden|screenSize" 是我找到的唯一解决方案,但应用程序在旋转时重新启动,我需要保留应用程序内容

从纵向开始 enter image description here

从横向开始 enter image description here

从横向开始并旋转屏幕到纵向(小操作栏和小字体高度) enter image description here

最佳答案

通过设置android:configChanges="orientation|keyboardHidden|screenSize"

您声明您将自行处理这些配置更改。在正常情况下,您不应该设置它,让 Android 重新创建您的 Activity。

编辑:

如果你想保留 android:configChanges 行,你必须覆盖 onConfigChanged() 并更改你自己需要的一切,例如ActionBar/ToolBar 的大小。

关于Android - ActionBar 未使用 onConfigurationChanged ( AppCompat ) 调整大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32434609/

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