Making DialogFragment window scrollable

Viewed 4894

I'm having a problem where Dialogs don't scroll when their content is too large for the screen. I assume this is because Dialogs are not displayed within Scrollable containers.

enter image description here

Screenshot contains content wrapped in a ScrollView - You can see only the content is scrollable

Extra fields added to artificially increase dialog size for this example

You can see from the Android Developer Documentation that Dialogs should be wrapped within DialogFragments (This gives the benefit of having your dialogs survive an orientation change and response to lifecycle events) and this is the set up I'm trying to make work.

Much of the other answers I've found are all similar to one another and revolve around ensuring the window is set to "adjustResize". However, this would only make the parent view smaller on keyboard opening, it wouldn't make a View scrollable if it wasn't in a Scrollable container.

If someone could let me know if they have info to make a Dialog scrollable or to confirm that you cannot make a Dialog scrollable I'd appreciate it.

3 Answers

I have achieved scrolling in dialog fragment,

Dialog layout design

<LinearLayout>
 <NestedScrollView>
   <ConstrainLayout>
   </ConstrainLayout>
 </NestedScrollView>
</LinearLayout>

In DialogFrament class ,

override fun onStart() {
  super.onStart()
       dialog.window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZ)
    }
Related