Android 键盘不会将布局推到编辑文本上方

Android 键盘不会将布局推到编辑文本上方,android,android-layout,mobile,Android,Android Layout,Mobile,在我的应用程序中,我有以下布局: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <Relative

在我的应用程序中,我有以下布局:

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <RelativeLayout
            android:id="@+id/fragment_container"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1" />

        <EditText
            android:id="@+id/edit_text"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:background="@color/text"
            android:gravity="center_horizontal"
            android:hint="@string/input_hint"
            android:inputType="textVisiblePassword"
            android:padding="@dimen/margin"
            android:singleLine="true"
            android:textColor="@color/input_text"
            android:textColorHint="@color/input_hint">
        </EditText>

    </LinearLayout>


单击EditText时,键盘会向上推屏幕(包括操作栏),使EditText正好位于键盘上方。我想要的是键盘上只出现EditText,但上面的FragmentContainer“作为背景”保持不变。我通过在AndroidManifest.xml文件中使用android:windowSoftInputMode=“adjustResize”获得了一些这方面的信息,但我的应用程序是全屏的,而且这个标记显然不能与全屏一起工作。

据我所知,无法实现您所描述的

以下是可供您选择的
windowSoftInputMode

  • adjustNothing
    :当键盘出现时,窗口根本不调整。这将阻止移动或调整
    fragment\u容器的大小,但也会导致键盘覆盖文本输入字段

  • adjustResize
    :当键盘出现时,窗口垂直“收缩”。这将导致
    fragment\u容器
    占用的空间小于键盘关闭时的空间,可能会影响片段布局

  • adjustPan
    :当键盘出现时,屏幕向上“推”。这将导致
    片段\u容器的顶部被屏幕边缘夹住

  • adjustUnspecified
    :允许系统在上述三个选项之间进行选择

下面是一些(希望)有助于说明这些属性的图片

键盘关闭时的布局


从左到右:
adjustNothing
adjustResize
adjustPan
据我所知,没有办法实现您所描述的

以下是可供您选择的
windowSoftInputMode

  • adjustNothing
    :当键盘出现时,窗口根本不调整。这将阻止移动或调整
    fragment\u容器的大小,但也会导致键盘覆盖文本输入字段

  • adjustResize
    :当键盘出现时,窗口垂直“收缩”。这将导致
    fragment\u容器
    占用的空间小于键盘关闭时的空间,可能会影响片段布局

  • adjustPan
    :当键盘出现时,屏幕向上“推”。这将导致
    片段\u容器的顶部被屏幕边缘夹住

  • adjustUnspecified
    :允许系统在上述三个选项之间进行选择

下面是一些(希望)有助于说明这些属性的图片

键盘关闭时的布局

从左到右:
adjustNothing
adjustResize
adjustPan