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.
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>
Make the Parent of the LinearLayout containing the button as relative and set the property of linear layout containing two buttons as android:layout_alignParentBottom="true". You can also set the gravity of the Linear Layout to Bottom. Save this answer.
How do I stop my keyboard from pushing up my screen? Add android:windowSoftInputMode="stateHidden|adjustPan" in required activity of your manifest file . This makes keyboard appear overlaying content, without making layout to recalculate it's height.
In AndroidManifest.xml
, set android:windowSoftInputMode="adjustPan"
to your activity.
Like this.
<activity
android:windowSoftInputMode="adjustPan">
Or:
<activity
android:windowSoftInputMode="adjustPan|adjustResize">
Also you can do this Programmatically.
Use this code in
onCreate()
method:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
Check this for Reference.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With