【发布时间】:2016-03-10 17:57:10
【问题描述】:
我已经阅读了有关此问题的多个讨论,当尝试获取 LinearLayout 的 ScrollView 以在显示键盘时进行调整时,它与清单文件的 android:windowSoftInputMode="stateHidden|adjustResize"(以及 adjustPan)有关。
我有一个布局,它在包含 10 个 LinearLayout 部分(TextView/EditText 视图)的 ScrollView 内有一个 LinearLayout。我已经尝试了我读过的所有组合,无论如何,当由于单击顶部 EditText 而打开键盘时,会调整(平移)视图,使顶部字段位于操作栏后面。我可以滚动到页面底部,但无法到达顶部 EditText - 我只能滚动到第二个。我可以尝试下拉,我可以开始看到顶部的 EditText 但无法显示它,除非我关闭键盘(显然我无法编辑文本)。
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.example.myproject.FirstActivity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/scrollView"
tools:showIn="@layout/activity_work"
android:layout_gravity="center_horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="x1"
android:layout_weight="50"/>
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:ems="10"
android:id="@+id/work_one"
android:hint="0"
android:gravity="right"
android:selectAllOnFocus="true"
android:textAlignment="gravity"
android:layout_weight="50" />
</LinearLayout>
.
. (9 more of these)
.
</LinearLayout>
</ScrollView>
更新:
所以我尝试了:android:windowSoftInputMode="adjustResize" 和/或 android:windowSoftInputMode="adjustPan" 并且软键盘会移动操作栏下方的顶部字段。
想法?
【问题讨论】:
-
嘿,我也面临同样的问题。你解决过这个问题吗?
标签: android android-layout android-scrollview