adjustPan and adjustResize in nested fragment

2019-05-29 23:59发布

问题:

I use a ViewPager and inside the first fragment of the ViewPager I have a another fragment that is parenting a sub fragment with ScrollView in it. to make it more visual:

┌------------┐
|   1        | 1 is the ViewPager fragment
| ┌---------┐|
| | 2       || 2 is the fragment inside ViewPager fragment
| |┌-------┐||
| ||3      ||| 3 is the sub fragment containing the ScrollView with EditText form
| ||form   |||
| ||here   |||
| ||       |||
| |└-------┘||
| └---------┘|
└------------┘

Issue is:

when I use adjustResize it allows me to scroll the fragment 3 ScrolView till end but when screen is too small, the ScrollView hides behind the SoftKeyboard and it does not push the parent fragments up to display fragment 3.

when I use adjustPan in small screens it pushes the the parent fragments up and allows me to see the 'fragment 3' but when I scroll, some of the ScrollView hides behind the soft keyboard.

I have done some reading in SO and android docs. they all point at using AdjustResize with ScrollView. but in my case i need to push the parent fragments up in small screens, otherwise the ScrollView in fragment3 will be covered by SoftKeyboard.

is it possible to do adjustPan in parent fragment and adjustResize for child fragment with scrollview at the same time ? if not is there any workarounds?

your helps are appreciated!

回答1:

Test "stateHidden|adjustResize" for parent activity.For me, It was the only way to over come a situation like yours