Android 软键盘遮住了 ScrollView 中的 EditTexts [英] Android Soft Keyboard Obscures EditTexts in ScrollView
问题描述
我有一个 TableLayout,它在 ScrollView 中填充了_parent.一切正常,除非显示软键盘时它会遮挡最后几个 EditText.从技术上讲,屏幕不能再向下滚动,因为没有键盘显示,屏幕适合所有内容.只是当键盘显示时,我无法向下滚动以查看剩余的 EditTexts 而不隐藏键盘并允许用户只选择并将值输入到较低的 EditTexts 之一中.使用 this,我试过:
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);
和
Window.SetSoftInputMode((int)SoftInput.AdjustResize);
和
[Activity(WindowSoftInputMode = SoftInput.AdjustPan)]
和
[Activity(WindowSoftInputMode = SoftInput.AdjustResize)]
和
Window.SetFlags(WindowManagerFlags.AltFocusableIm, WindowManagerFlags.AltFocusableIm);
那只是阻止了键盘的出现.这不是我需要的.我需要调整我的内容以在可见时显示在键盘上方,以便我可以继续滚动到显示键盘的最底部 EditText.很长的 xml 的摘录.该表在代码中动态填充.
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.
Probably not the most elegant solution but decided to just add a large marginBottom to the last row.
这篇关于Android 软键盘遮住了 ScrollView 中的 EditTexts的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!