From 7f3c12fe2c27f5b4f6e05211f188303ce752ae7e Mon Sep 17 00:00:00 2001 From: wisnu kurniawan Date: Mon, 23 Sep 2019 17:23:14 +0700 Subject: [PATCH] Support small screen --- .../datetimerangepickerandroid/CalendarRowView.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/datetimerangepickerandroid/src/main/java/com/wisnu/datetimerangepickerandroid/CalendarRowView.java b/datetimerangepickerandroid/src/main/java/com/wisnu/datetimerangepickerandroid/CalendarRowView.java index 0eb573b..c35cd42 100644 --- a/datetimerangepickerandroid/src/main/java/com/wisnu/datetimerangepickerandroid/CalendarRowView.java +++ b/datetimerangepickerandroid/src/main/java/com/wisnu/datetimerangepickerandroid/CalendarRowView.java @@ -36,6 +36,7 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { final int totalWidth = MeasureSpec.getSize(widthMeasureSpec); int rowHeight = 0; int cellHeightSpec = makeMeasureSpec(totalWidth, AT_MOST); + boolean isSmallScreen = getContext().getResources().getDisplayMetrics().density <= 1.5f; // HDPI for (int c = 0, numChildren = getChildCount(); c < numChildren; c++) { final View child = getChildAt(c); // Calculate width cells, making sure to cover totalWidth. @@ -49,7 +50,15 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { child.measure(cellWidthSpec, cellHeightSpec); // The row height is the height of the tallest cell. if (child.getMeasuredHeight() > rowHeight) { - rowHeight = child.getMeasuredHeight(); + if (isSmallScreen) { + if (isHeaderRow) { + rowHeight = child.getMeasuredHeight(); + } else { + rowHeight = cellSize; + } + } else { + rowHeight = child.getMeasuredHeight(); + } } } final int widthWithPadding = totalWidth + getPaddingLeft() + getPaddingRight();