Reputation: 553
I want to use the soft keyboard, but it hides my EditText or buttons, I need it to scroll so the keyboard is not hiding it. It's working very well with Activity, but not working with Fragment.
I'm trying with this code:
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE|WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
}
And also try this code:
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
}
Anybody got any suggestions for Fragment?
Upvotes: 2
Views: 1206
Reputation: 4132
Try this in the manifest of the particular activity
<activity
android:name=".YourActivity"
android:label="@string/app_name"
android:windowSoftInputMode="stateAlwaysHidden|adjustResize/>
or in the oncreate of the activity
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
Upvotes: 2