软键盘上升时如何使按钮停留在底部 [英] How to make button stay on the bottom when soft keyboard goes up
本文介绍了软键盘上升时如何使按钮停留在底部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在屏幕底部有一个按钮,即使软键盘向上移动,我也希望它保持按下状态,但是当前它与软键盘一起向上移动.我试图将按钮的底部对齐,但没有成功.
I have a button at the bottom of the screen and I want it to stay down even if soft keyboard goes up, but currently it goes up with soft keyboard. I tried to align the button to bottom but with no success.
这是代码(按钮在id/activity_form_button_frame中):
Here is the code (buttons are within 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>
推荐答案
在AndroidManifest.xml
中,将android:windowSoftInputMode="adjustPan"
设置为您的活动.
In AndroidManifest.xml
, set android:windowSoftInputMode="adjustPan"
to your activity.
赞.
<activity
android:windowSoftInputMode="adjustPan">
或:
<activity
android:windowSoftInputMode="adjustPan|adjustResize">
您也可以通过编程方式执行此操作.
在
onCreate()
方法中使用以下代码:
Use this code in
onCreate()
method:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
在参考中进行检查.
这篇关于软键盘上升时如何使按钮停留在底部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文