91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

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

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

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

婺源县| 靖州| 房产| 凤阳县| 都江堰市| 贡觉县| 枣阳市| 平罗县| 梧州市| 紫金县| 乌兰浩特市| 郓城县| 阜新| 长兴县| 永宁县| 宜兴市| 武威市| 黑水县| 化德县| 资兴市| 英德市| 工布江达县| 汝南县| 若尔盖县| 紫云| 宜兰县| 盐池县| 嘉义县| 仁布县| 谢通门县| 蒙自县| 宜良县| 德兴市| 开封县| 昌图县| 鹤庆县| 若尔盖县| 大余县| 灵寿县| 陇南市| 灵璧县|