Android 将框架布局与键盘顶部对齐

Android 将框架布局与键盘顶部对齐,android,android-layout,Android,Android Layout,在我的应用程序的一些片段中,我在页面底部有一个EditText。问题是,当键盘打开时,键盘与页面底部重叠,因此无法看到编辑文本。是否可以将包含碎片的FrameLayout底部与键盘顶部对齐 包含框架布局的活动视图: <?xml version="1.0" encoding="utf-8"?> <com.myapp.Layouts.FullDrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"

在我的应用程序的一些片段中,我在页面底部有一个EditText。问题是,当键盘打开时,键盘与页面底部重叠,因此无法看到编辑文本。是否可以将包含碎片的FrameLayout底部与键盘顶部对齐

包含框架布局的活动视图:

<?xml version="1.0" encoding="utf-8"?>
<com.myapp.Layouts.FullDrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity_">

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <include layout="@layout/view_toolbar" />

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <FrameLayout
                android:id="@+id/content_frame"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_above="@+id/view_menu_bar" />

            <include layout="@layout/view_menu_bar"
                android:layout_height="@dimen/menu_bar_height"
                android:layout_width="fill_parent"
                android:layout_alignParentBottom="true"
                android:id="@+id/view_menu_bar" />
        </RelativeLayout>
    </LinearLayout>

    <include layout="@layout/view_drawer"
        android:id="@+id/drawer"
        />

</com.myapp.Layouts.FullDrawerLayout>

在manifest.xml中找到该活动,并设置android:WindowsOfInputMode=adjustResize,如下所示:

<activity android:name=".YourActivity"
          android:windowSoftInputMode="adjustResize">
</activity>
来源:

试试:

<activity
    android:windowSoftInputMode="adjustPan"/>
或:


这似乎是一个bug,当你从一个片段打开键盘时,adjustResize无法工作。我使用/

AdjustPan中的代码修复了这个问题,它只是将整个页面向上移动,而不仅仅是框架布局的高度。AdjustResize没有做任何事情。这不是一个解决方案吗?您可以使用FrameLayout.setTranslateY来移动FrameLayout。但我还需要在键盘打开时向下滚动的可能性。因此,当键盘打开时,我需要框架布局与屏幕顶部和键盘顶部对齐。我想知道为什么adjustResize什么都没做。为什么你认为adjustResize什么都没做?我认为它做了它需要做的。但是你没有找到它!如果你想滚动,你需要在片段中有一个滚动视图。试过了,也试过了。两者都不起作用。
<activity
    android:windowSoftInputMode="adjustResize"/>