Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-19855] Android: Fix tableview layout. #7417

Merged
merged 1 commit into from
Nov 11, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import android.os.Handler;
import android.view.Gravity;
import android.view.View;
import android.view.View.MeasureSpec;
import android.widget.RelativeLayout;
import android.widget.TextView;

Expand Down Expand Up @@ -115,7 +116,13 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
{
measureChildren(widthMeasureSpec, heightMeasureSpec);
int w = MeasureSpec.getSize(widthMeasureSpec);
int h = Math.max(MeasureSpec.getSize(heightMeasureSpec), getSuggestedMinimumHeight());
int h = 0;
// If measure spec is not specified, height should behave as Ti.UI.SIZE
if (MeasureSpec.getMode(heightMeasureSpec) == MeasureSpec.UNSPECIFIED) {
h = getSuggestedMinimumHeight();
} else {
h = Math.max(MeasureSpec.getSize(heightMeasureSpec), getSuggestedMinimumHeight());
}
setMeasuredDimension(resolveSize(w, widthMeasureSpec), resolveSize(h, heightMeasureSpec));

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -506,21 +506,26 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
}

if (height == null) {
h = Math.max(h, Math.max(content.getMeasuredHeight(), Math.max(leftImageHeight, rightImageHeight)));
h = Math.max(h, minRowHeight);
// If measure spec is not specified, height should behave as Ti.UI.SIZE
if (hMode == 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably better if in the future magic numbers not used if possible although comments have the info.
I.e. 0 when I assume it's MeasureSpec.UNSPECIFIED

h = Math.max(content.getMeasuredHeight(), Math.max(leftImageHeight, rightImageHeight));
} else {
h = Math.max(h, Math.max(content.getMeasuredHeight(), Math.max(leftImageHeight, rightImageHeight)));
}
h = Math.max(h, minRowHeight);
} else {
h = Math.max(minRowHeight, height.getAsPixels(this));
h = Math.max(minRowHeight, height.getAsPixels(this));
}
// Make sure the height is greater than 1 (not 0 since image views default to 1)
if (hasChildView && h > 1) {
content.getLayoutParams().height = h;
content.getLayoutParams().height = h;
}

if (Log.isDebugModeEnabled()) {
Log.d(TAG, "Row content measure (" + adjustedWidth + "x" + h + ")", Log.DEBUG_MODE);
Log.d(TAG, "Row content measure (" + adjustedWidth + "x" + h + ")", Log.DEBUG_MODE);
}
measureChild(content, MeasureSpec.makeMeasureSpec(adjustedWidth, wMode),
MeasureSpec.makeMeasureSpec(h, hMode));
MeasureSpec.makeMeasureSpec(h, hMode));
}
}

Expand Down