What about setting RESIZE
instead of PAN
? You will be able to keep your EditText
above the SoftKeyboard
. Try as follows:
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
However, instead of doing this at runtime, you can set it in the manifest
as an Activity
(parent) attribute. This will also be handled in your fragment (child):
<activity
android:name=".NameActivity"
android:label="@string/app_name"
android:windowSoftInputMode="stateAlwaysHidden|adjustResize">
Then, as you can see, the EditText
is above the SoftKeyboard, but from your layout, you have a TextView
with android:layout_alignParentBottom="true"
attribute which will overlap the EditText
:
To prevent this behaviour, just set the ScrollView
above the last TextView
as follows:
<ScrollView
android:id="@+id/scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/ret"> <!-- instead of "footer" -->
And you will get the following result:
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…