Ask Your Question
4

How can the items on a form be moved up when the keyboard is opened?

asked 2022-02-19 11:00:00 +0000

djk gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-05-29 19:00:00 +0000

huitzilopochtli gravatar image

There are several ways to achieve this:

  1. Using ScrollView: Wrap the form container in a ScrollView and set the "android:windowSoftInputMode" attribute of the activity to "adjustResize". This will automatically adjust the layout when the keyboard is opened, pushing the form container up.

  2. Using LinearLayout: Set the height of the form container to "wrapcontent" and set the "android:layoutweight" attribute of any other elements in the container to "1". This will cause the form container to resize when the keyboard is opened, pushing the other elements up.

  3. Using CoordinatorLayout: Wrap the form container in a CoordinatorLayout and add the "app:layout_behavior" attribute to it with the value "android.support.design.widget.BottomSheetBehavior". This will create a bottom sheet that can be dismissed by dragging down, and will also automatically adjust the layout when the keyboard is opened.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-02-19 11:00:00 +0000

Seen: 7 times

Last updated: May 29 '21