当键盘弹出时,我的布局会发生改变。特别是注册按钮会向上移动并停留在一个EditText之上。我希望在键盘打开时保持视图大小不变,并能在较小的视口中滚动它。我尝试了android:windowSoftInputMode="adjustResize"(按钮被移动)和"adjustPan"(按钮不会被移动,但要看到按钮,您首先必须关闭键盘)。以下是我的xml文件:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffffff">
<LinearLayout
android:id="@+id/register_header"
android:orientation="horizontal"
android:gravity="center_vertical"
android:layout_width="match_parent"
android:layout_height="100dp"
android:padding="@dimen/activity_vertical_margin">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
... />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
... />
</LinearLayout>
<LinearLayout
android:id="@+id/register_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/register_header"
android:padding="@dimen/activity_vertical_margin"
android:orientation="vertical" >
// Bunch of EditText's here
</LinearLayout>
<LinearLayout
android:id="@+id/register_footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="center_vertical|bottom"
android:orientation="vertical"
android:padding="@dimen/activity_vertical_margin">
<Button
android:padding="16dp"
android:id="@+id/register_button_register"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/register" />
</LinearLayout>
</RelativeLayout>
adjustPan
。 - Cuddl3s