zoukankan      html  css  js  c++  java
  • android自适应滑动键盘产生的屏幕尺寸变化

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

    要不关闭activity 则可以在manifest.xml中增加 android:configChanges="keyboardHidden|orientation"

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

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

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

    android:screenOrientation="portrait">

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

    详细说明:

    <activity ...
              android:configChanges=[one or more of: "mcc" "mnc" "locale"
                                     "touchscreen" "keyboard" "keyboardHidden"
                                     "navigation" "orientation" "fontScale"]
    ...
    </activity>
    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.

  • 相关阅读:
    #特征方程,dp,快速幂#洛谷 4451 [国家集训队]整数的lqp拆分
    #状压dp,贪心#CF1316E Team Building
    #线段树,欧拉函数#CF1114F Please, another Queries on Array?
    #启发式合并,链表#洛谷 3201 [HNOI2009] 梦幻布丁
    #树状数组#洛谷 4113 [HEOI2012]采花
    #链表#洛谷 3794 签到题IV
    #矩阵乘法,斐波那契#洛谷 2544 [AHOI2004] 数字迷阵
    #dp#洛谷 4399 [JSOI2008]Blue Mary的职员分配
    #同余最短路#洛谷 3403 跳楼机
    #网络流,分层图#洛谷 4400 [JSOI2008] Blue Mary的旅行
  • 原文地址:https://www.cnblogs.com/jacktu/p/1392278.html
Copyright © 2011-2022 走看看