亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

activity中界面中edittext自動獲取焦點(軟鍵盤彈出)解決

發布時間:2020-06-16 15:20:22 來源:網絡 閱讀:2863 作者:poarry 欄目:移動開發

      最近在做開發的時候遇到個比較煩的問題就是 我的某個activity頁面中有editText,在一進去就會調用軟鍵盤,這樣看起來不美觀,所以看了下api

 http://developer.android.com/guide/topics/manifest/activity-element.html(要×××)

 

    在<Activity>節點下也就是在manifest文件的配置activity節點的時候需要配置

android:windowSoftInputMode 這個屬性來控制軟鍵盤的模式。我摘錄了一下api  相關軟鍵盤的片段如下:

android:windowSoftInputMode

  • How the main window of the activity interacts with the window containing the on-screen soft keyboard. The setting for this attribute affects two things:

    The setting must be one of the values listed in the following table, or a combination of one "state..." value plus one "adjust..." value. Setting multiple values in either group — multiple "state..." values, for example — has undefined results. Individual values are separated by a vertical bar (|). For example:

    <activity android:windowSoftInputMode="stateVisible|adjustResize" . . . >

    Values set here (other than "stateUnspecified" and "adjustUnspecified") override values set in the theme.

    ValueDescription
    "stateUnspecified"The state of the soft keyboard (whether it is hidden or visible) is not specified. The system will choose an appropriate state or rely on the setting in the theme.

    This is the default setting for the behavior of the soft keyboard.

    "stateUnchanged"The soft keyboard is kept in whatever state it was last in, whether visible or hidden, when the activity comes to the fore.
    "stateHidden"The soft keyboard is hidden when the user chooses the activity — that is, when the user affirmatively navigates forward to the activity, rather than backs into it because of leaving another activity.
    "stateAlwaysHidden"The soft keyboard is always hidden when the activity's main window has input focus.
    "stateVisible"The soft keyboard is visible when that's normally appropriate (when the user is navigating forward to the activity's main window).
    "stateAlwaysVisible"The soft keyboard is made visible when the user chooses the activity — that is, when the user affirmatively navigates forward to the activity, rather than backs into it because of leaving another activity.
    "adjustUnspecified"It is unspecified whether the activity's main window resizes to make room for the soft keyboard, or whether the contents of the window pan to make the current focus visible on-screen. The system will automatically select one of these modes depending on whether the content of the window has any layout views that can scroll their contents. If there is such a view, the window will be resized, on the assumption that scrolling can make all of the window's contents visible within a smaller area.

    This is the default setting for the behavior of the main window.

    "adjustResize"The activity's main window is always resized to make room for the soft keyboard on screen.
    "adjustPan"The activity's main window is not resized to make room for the soft keyboard. Rather, the contents of the window are automatically panned so that the current focus is never obscured by the keyboard and users can always see what they are typing. This is generally less desirable than resizing, because the user may need to close the soft keyboard to get at and interact with obscured parts of the window.

    This attribute was introduced in  API Level 3.

     

    瀏覽了下大概了解下也就是說這個配置主要是做兩件事請

    1、當activity獲取焦點的時候來設置軟鍵盤是否可見。

    2、(在軟鍵盤變小的時候留出空間,或者activity包含一個軟鍵盤布局同時這個activity獲取焦點的時候【pan 在這里翻譯的應該是面板,學過java GUI 的都知道有個panle】)調整以適應activity 的大小。

    同時這有很多獨立的屬性可以去設置,如果你想要設置的屬性在其中沒有的話你可以嘗試著用以上的屬性組合一下,只要組合的時候用“|”分開就好了。

  • 跑題了 ,我們要的效果是在當前的activity中有edittext,但是默認不彈出,只有當獲取焦點的時候才彈出軟鍵盤,那么我們根據屬性可以看下

adjustUnspecified | stateHidden 這個組合起來應該可以達到我們要的效果。因此我們在activity的節點上配置入下:< Activity   android:windowSoftInputMode="stateHidden|adjustUnspecified">

其他的效果可以根據api文檔說明進行設置。

 英語水平有限,歡迎指正錯誤 
 /**
 *
 *  
 **/

 

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

紫金县| 黄梅县| 罗田县| 新龙县| 克拉玛依市| 鞍山市| 图们市| 多伦县| 平远县| 准格尔旗| 仙桃市| 长治县| 凯里市| 时尚| 佳木斯市| 皋兰县| 香河县| 登封市| 镇远县| 文昌市| 九寨沟县| 西吉县| 阿合奇县| 佛教| 红河县| 长寿区| 荆州市| 建阳市| 武宁县| 安吉县| 旬邑县| 九龙坡区| 利辛县| 鄂托克前旗| 固阳县| 嵩明县| 黄冈市| 张掖市| 海宁市| 从江县| 东光县|