Android 输入法键盘遮挡控件问题的解决办法

来源:互联网 发布:数据的真实性 编辑:程序博客网 时间:2024/05/18 01:40

输入法键盘遮挡控件,有两种办法可以解决:

第一种:

在 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中,所有的文本框在输入法面板弹出的时候都会自动的向上滚动。期望对大家有帮助







原创粉丝点击