当软键盘上升时,如何使按钮保持在底部

bvk*_*256 6 android android-layout

我在屏幕底部有一个按钮,即使软键盘上升,我也希望它能保持稳定,但目前它还是软键盘.我试图将按钮对齐到底部,但没有成功.

这是代码(按钮在id/activity_form_button_frame中):

<RelativeLayout>
     <RelativeLayout
        android:id="@+id/activity_form_button_frame"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true">
    <ImageButton
        android:id="@+id/activity_form_next_button"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="@android:color/black"
        android:src="@drawable/next_btn_drawable"
        android:scaleType="fitCenter"
        android:padding="5dp"
        />
    <Button
        android:id="@+id/activity_form_sumbit_button"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="@android:color/black"
        android:text="SUBMIT"
        android:textColor="@color/buttonBlue"
        android:visibility="gone"
        android:padding="15dp"
        style="@android:style/TextAppearance.Large"/>
    </RelativeLayout>

    <FrameLayout
        android:id="@+id/activity_form_fragmentcontainer"
        android:layout_below="@id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@id/activity_form_button_frame"/>

    </RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

Jay*_* RJ 10

AndroidManifest.xml,设置android:windowSoftInputMode="adjustPan"为您的活动.

像这样.

<activity
    android:windowSoftInputMode="adjustPan">
Run Code Online (Sandbox Code Playgroud)

要么:

<activity
    android:windowSoftInputMode="adjustPan|adjustResize">
Run Code Online (Sandbox Code Playgroud)

您也可以通过编程方式执行此操作.

onCreate()方法中使用此代码:

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
Run Code Online (Sandbox Code Playgroud)

选中此参考.