I\'ve a DialogFragment.
Layout:
I had the same problem. I extended the RecyclerViewas follows:
public class MaxHeightRecyclerView extends RecyclerView {
private static final int MAX_HEIGHT = 765;
public MaxHeightRecyclerView(Context context) {
super(context);
}
public MaxHeightRecyclerView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
public MaxHeightRecyclerView(Context context, @Nullable AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
protected void onMeasure(int widthSpec, int heightSpec) {
heightSpec = MeasureSpec.makeMeasureSpec((int) (MAX_HEIGHT / Resources.getSystem().getDisplayMetrics().density), MeasureSpec.AT_MOST);
super.onMeasure(widthSpec, heightSpec);
}
}