Android 軟鍵盤遮擋控件的解決辦法

今天對應一個Android 軟鍵盤遮擋控件的BUG票,就是一個頁面最下面控件,除非軟鍵盤,軟鍵盤會遮住控件一部分。很困惑,上網GOOGLE了一下,發現很多人有這哥問題。

他們的解決辦法是在 AndroidManifest.xml中 找到對應activity  在裏面寫上android:windowSoftInputMode="adjustPan"

很高興的是嘗試,但是發現並沒有預期效果。

 

最後發現一個好辦法解決此問題,就是在 XML的頂級元素上加一層ScrollView

 

例如:

<?xml version="1.0" encoding="utf-8"?>

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="fill_parent" android:layout_height="fill_parent">
 <LinearLayout android:layout_width="fill_parent"
  android:layout_height="fill_parent" android:orientation="vertical">

  <include android:layout_width="fill_parent"
   android:layout_height="wrap_content" layout="@layout/title_navi" />
  <ViewFlipper android:id="@+id/vfSeason"
   android:layout_width="fill_parent" android:layout_height="fill_parent"
   android:persistentDrawingCache="animation" android:flipInterval="1000"
   android:inAnimation="@anim/slide_in" android:outAnimation="@anim/slide_out">

   <TableLayout android:layout_width="fill_parent"
    android:layout_height="fill_parent" android:stretchColumns="0">
    。
    。
    。
    。
   </TableLayout>


  </ViewFlipper>
 </LinearLayout>
</ScrollView>

 

 

利用ScrollView在 最外層包一層,問題解決。 因爲ScrollView中,所有的文本框在輸入法面板彈出的時候都會自動的向上滾動。期望對大家有幫助


http://godelta.blog.sohu.com/177789446.html

發佈了41 篇原創文章 · 獲贊 2 · 訪問量 4萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章