【发布时间】:2015-09-17 17:32:16
【问题描述】:
我有一个带有一些 TextViews/EditTexts 的 ScrollView,以便构建一个注册表单。
当我点击我的 EditText 时,ScrollView 按预期滚动(EditText 就在软键盘上方)。
但是如果我开始在其中输入一些文本,则 ScrollView 会在顶部滚动(EditText 被键盘覆盖)。
如果我删除我输入的文本,ScrollView 会再次滚动到合适的位置。
有人遇到过这个问题吗?
这是我的布局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="10"
android:paddingTop="5dp"
android:paddingBottom="5dp">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="5"
android:drawableLeft="@drawable/my_drawable"
android:drawablePadding="5dp"
android:text="Some text"
android:textStyle="bold" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="5"
android:orientation="vertical">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:drawableLeft="@drawable/my_drawable_2"
android:text="My button"
android:textAllCaps="true" />
<EditText
android:background="@drawable/my_background"
android:padding="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:hint="1234567896324"
android:imeOptions="actionDone"
android:inputType="number"
android:maxLength="19"
android:singleLine="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Explanation"
android:textColor="#d3d3d3"
android:textSize="12sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
【问题讨论】:
-
我的清单中已经有了 android:windowSoftInputMode="adjustPan"
标签: android android-layout android-scrollview