edit:
I need to use the keyboard, but it hides my EditText
, I need it to scroll so the keyboard is not hiding it.
I am using a Samsun
Change this to LinearLayout:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
to
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">
(and the closing tag). Note the orientation.
Update the manifest Remove this:
<application ... >
<activity
android:windowSoftInputMode="stateVisible|adjustResize|adjustPan">
...
</activity>
...
</application>
Change this (height):
<ScrollView
android:layout_height="wrap_content"
android:layout_width="match_parent">
Try to use WindowsSoftInputMode
as adjustpan
only.
For ex:
android:windowSoftInputMode="adjustPan"
Before show your Snackbar widget hide the keyboard like this,
public void showSnackBar(){
InputMethodManager manager = (InputMethodManager)getActivity().getSystemService(Activity.INPUT_METHOD_SERVICE);
manager.hideSoftInputFromWindow(getView().getWindowToken(),0);
Snackbar snackbar = Snackbar.make(getView(), "Some message!", Snackbar.LENGTH_INDEFINITE).show();
}
What worked for me was using the ScrollView the same way as you in my FrameLayout, in which I added this property: android:windowSoftInputMode="adjustPan". At the end, it looks like this and it is working. I did not need to change anything programatically:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ProductFragment"
android:windowSoftInputMode="adjustPan">
<ScrollView
android:layout_height="wrap_content"
android:layout_width="match_parent">
...
</ScrollView>
</FrameLayout>
You can try to put this in onActivityCreated of your fragment:
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
This should not make the keyboard upon loading or starting of your activity with fragment.
keep in mind that hide keyboard does not work with getActivity().getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);