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>
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 .
try this....
<activity
android:windowSoftInputMode="adjustPan">
Try this
<activity
android:windowSoftInputMode="adjustPan">
or in code
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
Try add in manifest to your activity attribute android:windowSoftInputMode. Set it to adjustResize or adjustPan. One of these will work.
Inside your manifest file under your activity tag just add this line.
android:windowSoftInputMode="stateHidden|adjustResize"
For Example,
<activity
android:name="packagename.ClassName"
android:label="@string/app_name"
android:windowSoftInputMode="stateHidden|adjustResize" >
</activity>
And you are good to go.
Change at your AndroidManifest
file and at activity
to add property like
android:windowSoftInputMode="adjustResize"
to this direct to open keyboard to above button.
在活动标记下的清单文件中,添加以下行。
android:windowSoftInputMode="adjustPan|adjustResize"
In your AndroidManifest.xml
try this code:
<activity
android:name="com.facebook.FacebookActivity"
android:windowSoftInputMode="adjustPan|adjustResize"
android:label="@string/app_name"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
In my case, I was using <item name="android:windowFullscreen">true</item>
in my theme. It was creating problem and I used android:windowSoftInputMode="adjustResize"
along with that.
你可以使用android:layout_alignParentBottom="true"
。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.