Android Soft Keyboard Obscures EditTexts in ScrollView

I have a TableLayout that fills_parent inside of a ScrollView. Everything works perfectly except when the Soft Keyboard is shown it obscures the last few EditTexts. Technically, the screen can't be scrolled down any more since without the Keyboard showing, the screen fits all the content. It's just that when the Keyboard is showing, I can not scroll lower to see the remaining EditTexts without hiding the keyboard and allowing the user to just select and enter values into one of the lower EditTexts. Using this, I've tried:

Window.SetSoftInputMode((int)SoftInput.AdjustPan); 

and

Window.SetSoftInputMode((int)SoftInput.AdjustResize); 

and

[Activity(WindowSoftInputMode = SoftInput.AdjustPan)]

and

[Activity(WindowSoftInputMode = SoftInput.AdjustResize)]

and

Window.SetFlags(WindowManagerFlags.AltFocusableIm, WindowManagerFlags.AltFocusableIm);

That one just prevented the keyboard from coming up at all. Which isn't what I need. I need my content to adjust to be shown above the Keyboard when visible so that I can continue scrolling to the very bottom EditText with Keyboard shown. An excerpt from the very long xml. The table is dynamically populated in code.

<ScrollView
 android:id="@+id/peScroll"
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 android:layout_below="@id/security">
   <TableLayout
    android:id="@+id/poweredEquip"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_centerVertical="true"
    android:stretchColumns="*"
    android:gravity="center"
    android:padding="10dip">        
    <TableRow
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:background="@drawable/tab_bg_unselected"
      android:gravity="center">
      <TextView
        android:text="Serial"
        android:textSize="15sp"
        android:textColor="@android:color/black"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ellipsize="middle"
        android:gravity="center"
        android:layout_column="1"/>
     </TableRow>
  </TableLayout>
</ScrollView>

可能不是最优雅的解决方案,但决定只在最后一行添加一个大的marginBottom。

链接地址: http://www.djcxy.com/p/63690.html

上一篇: Android:ScrollView不能用键盘滚动

下一篇: Android软键盘在ScrollView中隐藏EditTexts