Skip to content

Commit

Permalink
Merge pull request #5 from wisnukurniawan/support-small-screen
Browse files Browse the repository at this point in the history
Support small screen
  • Loading branch information
wisnukurniawan authored Sep 23, 2019
2 parents 7122039 + 7f3c12f commit 02c121e
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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();
Expand Down

0 comments on commit 02c121e

Please sign in to comment.