I\'ve a DialogFragment
.
Layout:
You can achieve this using only XML as long as your parent layout is ConstraintLayout
, which yours seems to be. Make these changes to your RecyclerView
tag:
Normally you only use a 0dp
dimension when you constrain both sides of the view, but really all you have to do is provide enough constraints to define the view size (and constraining both sides is just the easiest way to do that). Once you have the height set to "match constraints", you can combine a default height constraint with a maximum height constraint to get exactly what you're looking for.
Note you must be using a 1.1 version of the constraint layout library for this. Make sure your app's build.gradle file has something like:
implementation 'com.android.support.constraint:constraint-layout:1.1.0-beta5'