Reputation: 449
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent">
<LinearLayout
android:layout_gravity="bottom"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</FrameLayout>
in manifest:
android:windowSoftInputMode="adjustPan"
Initial behavior:
Current behavior:
Desired behavior:
How to achive desired behavior of layout? adjustResize unsuitable because this option resizes layout.
Thank you for answers!
Upvotes: 21
Views: 12471
Reputation: 476
Just use this property in activity
android:windowSoftInputMode="adjustPan"
Upvotes: 0
Reputation: 5081
I don't believe there is a simple way to do this. At least not as simple as setting a flag. I had a similar situation of wanting the keyboard to rise to the level of Views well below the selected EditText. I ended up using this answer: How to check visibility of software keyboard in Android?
and manually adjusting my View sizes when the keyboard becomes visible.
Upvotes: 1
Reputation: 628
by removing below line from activity and android:windowSoftInputMode from manifest, I got whole layout scrolling which was previously hiding by
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
please check this output video link: https://mega.nz/#!TpRCWZjY!TqDzv0Yn3Q24PR1JAdH8kRVeDf2iSa1LQbNBgF0SVHk
Upvotes: 1
Reputation: 5020
You won't be able to implement that with adjustPan
, because from the official guide
The activity's main window is not resized to make room for the soft keyboard. Rather, the contents of the window are automatically panned so that the current focus is never obscured by the keyboard and users can always see what they are typing. This is generally less desirable than resizing, because the user may need to close the soft keyboard to get at and interact with obscured parts of the window.
Your Button
is below your current focus EditText
Upvotes: 1
Reputation: 12002
Try to change FrameLayout
to RelativeLayout
with alignParentBottom="true"
property in your LinearLayout
:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent">
<LinearLayout
android:layout_alignParentBottom="true"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</RelativeLayout>
Upvotes: 1
Reputation: 2577
try this one in your manifest:
android:windowSoftInputMode="adjustResize|stateUnchanged"
Upvotes: 2
Reputation: 8666
You probably want to take a look at this answer. A suggestion from it:
Set Window SoftInput Mode property to adjustPan and adjustResize
<activity android:windowSoftInputMode="adjustPan|adjustResize"> </activity>
Upvotes: 2
Reputation: 44
The only way to obtain that result is resize layout. Use android:windowSoftInputMode="adjustResize"
Upvotes: 2
Reputation: 580
the check if the layout that contain EditText and Button is RelativeLayout.
Upvotes: 1