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

标签 android android-actionbar android-appcompat

在我的应用程序 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/

相关文章:

android - 如何显示数据库中的古吉拉特语文本

Android 选项卡操作栏

android - getActivity().getActionBar() 在第一个 fragment 崩溃时

android - 单击设置图标时创建新 Activity

android - 如何在 Appcompat 22 中从汉堡包图标动态更改为向上图标

android - AppCompatv7 Android 5.0问题

Android SQLite "no such table"异常

java - AlarmManager 无需等待指定时间即可触发 Intent

toolbar - 支持工具栏的自定义 View 不使用全宽

android - 在自定义 ListView 上实现搜索