Android IME遮擋問題

來源:互聯網
上載者:User

http://www.eoeandroid.com/forum.php?mod=viewthread&tid=96904

Android IME遮擋問題http://www.eoeandroid.com/thread-23360-1-1.html在Android系統中,由於手機螢幕大小的限制,一般需要字元輸入的時候,彈出的IME面板往往會佔據大半個螢幕,如果輸入框正好在下方,那經常會出現被IME面板遮擋的尷尬,給使用者帶來不小的困擾,使用者體驗很不友好。

  查了一下android sdk的說明,發現可以通過設定Activity的一個屬性來解決這個問題,比如可以在AndroidManifest.xml中這樣寫:

java代碼:

< activity android:name=”.CategoryList”

android:label=”@string/app_name”

android:windowSoftInputMode=”stateAlwaysHidden|adjustResize” >

< /activity >

這裡面的android:windowSoftInputMode就是用來避免IME面板遮擋問題的,具體的參數說明可參考SDK文檔,但是,文檔中說明,該屬性是Android 1.5之後才加上的,也就是API Level 3以後的SDK才支援,那麼如果在聯想O1這樣的機器上就不管用了,則該怎麼辦呢?好在我又找到了另外一種解決辦法,就是ScrollView。我們可以在對應的layout XML的頂級元素上加一層ScrollView,這樣,在這個ScrollView中,所有的文字框在IME面板彈出的時候都會自動的向上滾動,範例程式碼如下:

java代碼:

< ScrollView xmlns:android=”http://schemas.android.com/apk/res/android “
android:layout_width=”fill_parent

android:layout_height=”fill_parent”

< LinearLayout android:orientation=”vertical”

android:layout_width=”fill_parent”

android:layout_height=”fill_parent” >

< EditText android:id=”@+id/content”
android:layout_width=”fill_parent”
android:layout_height=”wrap_content”
android:lines=”4″
android:scrollbars=”vertical”
android:gravity=”fill_horizontal” / >
< /LinearLayout >
< /ScrollView >

androidIME覆蓋最下方的編輯框問題manifest添加android:windowSoftInputMode參數,點擊編輯框後效果未點擊編輯框

manifest未添加android:windowSoftInputMode參數點擊編輯框後效果,最下方的表情按鍵被覆蓋

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.