当键盘出现 Android 时,EditText 超出 window 范围
EditText going beyond the window bound when keyboard comes in Android
在我的 manifest.xml 中,我已将其设置为我当前的 Activity
。
<activity
android:name=".StockAdjustment"
android:theme="@style/CustomActionBarTheme"
android:label="@string/Metrix"
android:windowSoftInputMode="adjustResize" >
</activity>
我的问题是当键盘出现时我的 EditText
调得太多了。它超出了视图的上限,甚至看不到我正在输入的内容。
无论我为 android:windowSoftInputMode="adjustResize"
输入什么,结果都是一样的。
请帮助我。
谢谢
更新
更新 2
<ScrollView
style="@style/ScrollViewBase.Normal.Vertical"
android:layout_weight="1"
tools:isScrollContainer="false">
设置android:windowSoftInputMode="stateVisible|adjustPan|adjustResize"
此外,如果您的布局中有 ScrollView
,请将 android:isScrollContainer="false"
添加到您的 ScrollView
试试这个并将 android:fitsSystemWindows="true"
设置为父布局元素。
<ScrollView
style="@style/ScrollViewBase.Normal.Vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:isScrollContainer="false">
最后,我通过更改 layout.xml 的结构实现了这一点。
我将我的布局 xml 文件更改为这个
<LinearLayout style="@style/LinearBase.Normal.Vertical" >
<ScrollView
style="@style/ScrollViewBase.Normal.Vertical"
android:layout_weight="1"
android:fitsSystemWindows="true"
tools:isScrollContainer="false">
<LinearLayout style="@style/LinearBase.Normal.Vertical">
<LinearLayout
android:id="@+id/table_layout"
style="@style/LinearBase.Normal.Vertical"
android:focusable="true"
android:focusableInTouchMode="true">
<TextView
style="@style/TextViewBase.Title"
android:tag="SCREEN_LABEL"></TextView>
<TextView
style="@style/TextViewBase.Emphasis"
android:tag="SCREEN_TIP"></TextView>
</LinearLayout>
<ListView
android:id="@+id/serialList"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</ScrollView>
<include layout="@layout/stock_adjustment_menu_bar" />
</LinearLayout>
之前我的Scrollview
是shrinking/paning,然后ListView
往上走,我就看不到ScrollView
里面的内容了。更改布局结构后,我的整个内容(通过代码添加的 Textviews、EditTexts 和 ListView)都在一个 ScrollView
中。所以 shrinking/paning 通过考虑 Scrollview
.
内部的全部内容而发生
确保在触摸 ListView
时禁用父视图的滚动
在我的 manifest.xml 中,我已将其设置为我当前的 Activity
。
<activity
android:name=".StockAdjustment"
android:theme="@style/CustomActionBarTheme"
android:label="@string/Metrix"
android:windowSoftInputMode="adjustResize" >
</activity>
我的问题是当键盘出现时我的 EditText
调得太多了。它超出了视图的上限,甚至看不到我正在输入的内容。
无论我为 android:windowSoftInputMode="adjustResize"
输入什么,结果都是一样的。
请帮助我。 谢谢
更新
更新 2
<ScrollView
style="@style/ScrollViewBase.Normal.Vertical"
android:layout_weight="1"
tools:isScrollContainer="false">
设置android:windowSoftInputMode="stateVisible|adjustPan|adjustResize"
此外,如果您的布局中有 ScrollView
,请将 android:isScrollContainer="false"
添加到您的 ScrollView
试试这个并将 android:fitsSystemWindows="true"
设置为父布局元素。
<ScrollView
style="@style/ScrollViewBase.Normal.Vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:isScrollContainer="false">
最后,我通过更改 layout.xml 的结构实现了这一点。 我将我的布局 xml 文件更改为这个
<LinearLayout style="@style/LinearBase.Normal.Vertical" >
<ScrollView
style="@style/ScrollViewBase.Normal.Vertical"
android:layout_weight="1"
android:fitsSystemWindows="true"
tools:isScrollContainer="false">
<LinearLayout style="@style/LinearBase.Normal.Vertical">
<LinearLayout
android:id="@+id/table_layout"
style="@style/LinearBase.Normal.Vertical"
android:focusable="true"
android:focusableInTouchMode="true">
<TextView
style="@style/TextViewBase.Title"
android:tag="SCREEN_LABEL"></TextView>
<TextView
style="@style/TextViewBase.Emphasis"
android:tag="SCREEN_TIP"></TextView>
</LinearLayout>
<ListView
android:id="@+id/serialList"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</ScrollView>
<include layout="@layout/stock_adjustment_menu_bar" />
</LinearLayout>
之前我的Scrollview
是shrinking/paning,然后ListView
往上走,我就看不到ScrollView
里面的内容了。更改布局结构后,我的整个内容(通过代码添加的 Textviews、EditTexts 和 ListView)都在一个 ScrollView
中。所以 shrinking/paning 通过考虑 Scrollview
.
确保在触摸 ListView