Skip to content

Commit

Permalink
Merge pull request #7417 from hieupham007/timob-19855
Browse files Browse the repository at this point in the history
[TIMOB-19855]: Fix tableview layout.
  • Loading branch information
ashcoding committed Nov 11, 2015
2 parents 85b719b + 0502017 commit 8d0f1a3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
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) {
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

0 comments on commit 8d0f1a3

Please sign in to comment.