Android的 - 动作条不onConfigurationChanged(AppCompat)调整 [英] Android - ActionBar not resizing with onConfigurationChanged ( AppCompat )

查看:286
本文介绍了Android的 - 动作条不onConfigurationChanged(AppCompat)调整的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序清单,我添加机器人:configChanges 以prevent活动重装/重启对旋转

In my application manifest I've add android:configChanges to prevent activity reload/restart on rotate

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

它的工作原理,但supportActionBar(我使用AppCompat)preserves他的身高小字体大小。

it works, but supportActionBar ( I'm using AppCompat ) preserves his height with small font size.

动作条应该是更大的纵向和更小的景观,但它保持初始值:

ActionBar should be bigger in portrait and smaller in landscape, but it keeps the initial value:

  • 如果我开始在景观,动作条保持身材苗条的画像
  • 如果我开始在纵向的动作条留在大山水

删除机器人:configChanges =定位| keyboardHidden |屏幕尺寸是我发现的唯一的解决办法,但在旋转的应用程序重新启动,我需要preserve应用内容

Removing android:configChanges="orientation|keyboardHidden|screenSize" is the only solution I've found, but the app restart on rotate, and I need to preserve application content

开始在纵向

开始在横向

开始在横向和旋转屏幕纵向(小行动起来吧,小字体高度)

推荐答案

通过设置安卓configChanges =定位| keyboardHidden |屏幕尺寸

您声明,您将处理由自己这些配置的变化。在正常情况下,你不应该设置,让Android的重新创建活动。

You declare that you will handle these config changes by yourself. In normal cases, you should not set that, and let Android recreate your Activity.

编辑:

如果你想保留该行安卓configChanges ,你必须重写 onConfigChanged()和改变一切需要自己,如在动作条/工具栏的大小。

If you want to keep the line android:configChanges, you have to override onConfigChanged() and change everything needed by yourself, e.g. the size of the ActionBar/ToolBar.

这篇关于Android的 - 动作条不onConfigurationChanged(AppCompat)调整的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆