我有一个活动,应该显示带有某些内容的FrameLayout或LinearLayout。 屏幕底部应有一个按钮。 Button和Layout都必须包装成某种东西,因为android只允许一个rootview。 我已经通过AndroidManifest.xml设置了" adjustResize"标志。 此标志应将按钮从软键盘的底部移至顶部。 问题是我无法实现这一点(按钮被隐藏在软键盘下-按钮不会移动)。 用显示的键盘将按钮移动到正确位置的唯一方法是用ScrollView替换Linear或Frame Layout。
我的问题是:为什么仅在ScrollView中起作用? 我已经在多个视图中使用了此方法,即使对于不同类型的视图组,它也始终有效。 有人有什么主意吗?
这是我的布局的样子:
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools">
style="@style/FirebaseUI.WrapperStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:id="@+id/email_layout"
style="@style/FirebaseUI.Text.TextInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="16dp"
android:transitionGroup="true"
android:transitionName="email_field"
app:errorTextAppearance="@style/FirebaseUI.Text.ErrorText"
app:hintTextAppearance="@style/FirebaseUI.Text.HintText"
tools:ignore="UnusedAttribute">
android:id="@+id/email"
style="@style/FirebaseUI.EditText.EmailField"/>
android:id="@+id/name_layout"
style="@style/FirebaseUI.Text.TextInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="112dp"
app:errorTextAppearance="@style/FirebaseUI.Text.ErrorText"
app:hintTextAppearance="@style/FirebaseUI.Text.HintText">
android:id="@+id/name"
style="@style/FirebaseUI.EditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:hint="@string/name_hint"/>
android:id="@+id/password_layout"
style="@style/FirebaseUI.Text.TextInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="224dp"
app:errorTextAppearance="@style/FirebaseUI.Text.ErrorText"
app:hintTextAppearance="@style/FirebaseUI.Text.HintText"
app:passwordToggleEnabled="true">
style="@style/FirebaseUI.EditText.PasswordField"
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
android:id="@+id/create_account_text"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_marginTop="336dp"
style="@style/FirebaseUI.Text.BodyText"/>
style="@style/FirebaseUI.Button"
android:layout_below="@id/create_account_text"
android:id="@+id/button_create"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:text="@string/button_text_save"/>
谢谢
您将在ID为create_account_text的TextView中添加336dp的marginTop。 在大多数设备中,这是很多事情,因此,当出现软键盘时,所显示的屏幕数量小于其他视图和336dp marginTop所需要的数量。
当您添加ScrollView时,当softKeyboard出现时,视图将滚动到底部,因此将显示按钮,而其他内容则不显示。
我不知道您的需要是什么,但是如果此336dp只是在屏幕上留有空白,则可以将RelativeLayout转换为LinearLayout并使用布局权重来填充空白,因此当键盘出现时, 空白空间将被调整。
如果您需要更多帮助,请提供屏幕截图。