Android: BottomSheetFragment Keyboard problem?

Leo N
Jun 16, 2019

Use this in your Dialog Fragment.

getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

Inside onCreateView like this.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

View rootView = inflater.inflate(R.layout.dialog_fragment, container);

//set to adjust screen height automatically, when soft keyboard appears on screen
getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);


return rootView;
}

Result

β€”

Keyboard with button at the bottom?

Imaging that, you have a button at the bottom, when keyboard open, it will be hidden, so how to solve this problem?

Try this code

Thanks for:

Thanks for reading, please feel free to comment with this post.

--

--

Leo N
Leo N

Written by Leo N

πŸ‡»πŸ‡³ πŸ‡ΈπŸ‡¬ πŸ‡²πŸ‡Ύ πŸ‡¦πŸ‡Ί Engineer @ GXS Bank, Singapore | MSc πŸŽ“ | Technical Writer . https://github.com/nphausg