设为首页 加入收藏

TOP

Android自适应滑动键盘产生的屏幕尺寸变化
2014-11-24 03:00:51 来源: 作者: 【 】 浏览:2
Tags:Android 适应 滑动 键盘 产生 屏幕 尺寸 变化

默认情况下,滑动键盘会重新启动activity


然后重载public void onConfigurationChanged(Configuration newConfig) 函数


键盘被抽出后会首先调用onConfigurationChanged


如果你希望滑动键盘不改变屏幕分辨率 则可以增加属性:


android:screenOrientation="portrait">


portrait :竖
landscape: 横
sensor:根据手机的角度自动调整



详细说明:


android:configChanges=[one or more of: "mcc" "mnc" "locale"
"touchscreen" "keyboard" "keyboardHidden"
"navigation" "orientation" "fontScale"]
...

android:configChanges
Lists configuration changes that the activity will handle itself. When changes that are not listed occur, the activity is shut down and restarted. When a listed change occurs, the activity remains running and its onConfigurationChanged() method is called.


Any or all of the following strings can be used to set this attribute. Values are separated by '|' — for example, "locale|navigation|orientation".
Value Description
"mcc" The IMSI mobile country code (MCC) has changed — that is, a SIM has been detected and updated the MCC.
"mnc" The IMSI mobile network code (MNC) has changed — that is, a SIM has been detected and updated the MNC.
"locale" The locale has changed — for example, the user has selected a new language that text should be displayed in.
"touchscreen" The touchscreen has changed. (This should never normally happen.)
"keyboard" The keyboard type has changed — for example, the user has plugged in an external keyboard.
"keyboardHidden" The keyboard accessibility has changed — for example, the user has slid the keyboard out to expose it.
"navigation" The navigation type has changed. (This should never normally happen.)
"orientation" The screen orientation has changed — that is, the user has rotated the device.
"fontScale" The font scaling factor has changed — that is, the user has selected a new global font size.


All of these configuration changes can impact the resource values seen by the application. Therefore, when onConfigurationChanged() is called, it will generally be necessary to again retrieve all resources (including view layouts, drawables, and so on) to correctly handle the change.


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Android 将图片扩大缩放的类 下一篇Android输入框被键盘遮挡

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·在 C 语言函数中,如 (2025-12-24 12:19:41)
·C盘里面的AppData文 (2025-12-24 12:19:38)
·c语言中的“%d,%s,%c (2025-12-24 12:19:35)
·Sphinx : 高性能SQL (2025-12-24 10:18:11)
·Pandas 性能优化 - (2025-12-24 10:18:08)