0

I have a ScrollView which contains a LinearLayout, which in turn contains many layouts and views.

I want to fix the size of views and layouts, so I used a weightSum attribute on the parents and layout_weight attribute on the children.

ScrollView should work when I open the keyboard, but what happens is one of 2 cases:

  • The views still fill the screen but ScrollView does not work, so I cannot see the views behind the keyboard.

  • The view's height reduces to fill the screen above the keyboard, and there is no need for the ScrollView.

What I expect is the views still fill the screen and ScrollView should work to see the items below.

StardustGogeta
  • 3,331
  • 2
  • 18
  • 32
Abdurrahman Anas
  • 665
  • 2
  • 9
  • 21

2 Answers2

0

Add android:windowSoftInputMode="stateHidden|adjustResize" to your tag in AndroidManifest.xml file inside your activity. This will cause the screen to be resized to the left over space after the soft keyboard is shown. So, you will be able to scroll easily.

Nitesh
  • 3,868
  • 1
  • 20
  • 26
0

Probably related to this

Add android:windowSoftInputMode="stateVisible|adjustResize" to your activity (it should be in the AndroidManifest.xml file)

That one should change the behavior for soft keyboard

As for views shrinking it's because of that weightSum. What it does is it makes a proportions - if the weightSum is say 1 and height is 500dp then a child view with weight is 0.5 will have height as 250dp. It will always be half no matter what.

What I would recommend is to use ConstraintLayout instead of LinearLayout. You can use barriers, chains or aspect ratios to achieve desired proportions. It is more complicated then LinearLayout, but gives you much more options. I assume you're using Android Studio, so you can use the graphical tool to make it easier for you.

Miku
  • 567
  • 6
  • 15