mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Fixed issue #360.
This commit is contained in:
@@ -16,7 +16,7 @@ public class WrapLayout extends LayoutBase {
|
|||||||
private int _itemWidth = -1;
|
private int _itemWidth = -1;
|
||||||
private int _itemHeight = -1;
|
private int _itemHeight = -1;
|
||||||
private Orientation _orientation = Orientation.horzontal;
|
private Orientation _orientation = Orientation.horzontal;
|
||||||
private ArrayList<Integer> _lenghts = new ArrayList<Integer>();
|
private ArrayList<Integer> _lengths = new ArrayList<Integer>();
|
||||||
|
|
||||||
public WrapLayout(Context context) {
|
public WrapLayout(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
@@ -82,9 +82,9 @@ public class WrapLayout extends LayoutBase {
|
|||||||
|
|
||||||
int count = this.getChildCount();
|
int count = this.getChildCount();
|
||||||
|
|
||||||
this._lenghts.clear();
|
this._lengths.clear();
|
||||||
int rowOrColumn = 0;
|
int rowOrColumn = 0;
|
||||||
int maxLenght = 0;
|
int maxLength = 0;
|
||||||
|
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
View child = this.getChildAt(i);
|
View child = this.getChildAt(i);
|
||||||
@@ -99,10 +99,10 @@ public class WrapLayout extends LayoutBase {
|
|||||||
if (isVertical) {
|
if (isVertical) {
|
||||||
if (childMeasuredHeight > remainingHeight) {
|
if (childMeasuredHeight > remainingHeight) {
|
||||||
rowOrColumn++;
|
rowOrColumn++;
|
||||||
maxLenght = Math.max(maxLenght, measureHeight);
|
maxLength = Math.max(maxLength, measureHeight);
|
||||||
measureHeight = childMeasuredHeight;
|
measureHeight = childMeasuredHeight;
|
||||||
remainingWidth = height - childMeasuredHeight;
|
remainingWidth = height - childMeasuredHeight;
|
||||||
this._lenghts.add(rowOrColumn, childMeasuredWidth);
|
this._lengths.add(rowOrColumn, childMeasuredWidth);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
remainingHeight -= childMeasuredHeight;
|
remainingHeight -= childMeasuredHeight;
|
||||||
@@ -112,10 +112,10 @@ public class WrapLayout extends LayoutBase {
|
|||||||
else {
|
else {
|
||||||
if (childMeasuredWidth > remainingWidth) {
|
if (childMeasuredWidth > remainingWidth) {
|
||||||
rowOrColumn++;
|
rowOrColumn++;
|
||||||
maxLenght = Math.max(maxLenght, measureWidth);
|
maxLength = Math.max(maxLength, measureWidth);
|
||||||
measureWidth = childMeasuredWidth;
|
measureWidth = childMeasuredWidth;
|
||||||
remainingWidth = width - childMeasuredWidth;
|
remainingWidth = width - childMeasuredWidth;
|
||||||
this._lenghts.add(rowOrColumn, childMeasuredHeight);
|
this._lengths.add(rowOrColumn, childMeasuredHeight);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
remainingWidth -= childMeasuredWidth;
|
remainingWidth -= childMeasuredWidth;
|
||||||
@@ -123,25 +123,25 @@ public class WrapLayout extends LayoutBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this._lenghts.size() <= rowOrColumn) {
|
if(this._lengths.size() <= rowOrColumn) {
|
||||||
this._lenghts.add(rowOrColumn, isVertical ? childMeasuredWidth : childMeasuredHeight);
|
this._lengths.add(rowOrColumn, isVertical ? childMeasuredWidth : childMeasuredHeight);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this._lenghts.set(rowOrColumn, Math.max(this._lenghts.get(rowOrColumn), isVertical ? childMeasuredWidth : childMeasuredHeight));
|
this._lengths.set(rowOrColumn, Math.max(this._lengths.get(rowOrColumn), isVertical ? childMeasuredWidth : childMeasuredHeight));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
count = this._lenghts.size();
|
count = this._lengths.size();
|
||||||
if (isVertical) {
|
if (isVertical) {
|
||||||
measureHeight = Math.max(maxLenght, measureHeight);
|
measureHeight = Math.max(maxLength, measureHeight);
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
measureWidth += this._lenghts.get(i);
|
measureWidth += this._lengths.get(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
measureWidth = Math.max(maxLenght, measureWidth);
|
measureWidth = Math.max(maxLength, measureWidth);
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
measureHeight += this._lenghts.get(i);
|
measureHeight += this._lengths.get(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,7 +170,7 @@ public class WrapLayout extends LayoutBase {
|
|||||||
|
|
||||||
int childLeft = paddingLeft;
|
int childLeft = paddingLeft;
|
||||||
int childTop = paddingTop;
|
int childTop = paddingTop;
|
||||||
int childrenLength = isVertical ? bottom - top - (paddingRight + paddingBottom) : right - left - (paddingLeft + paddingRight);
|
int childrenLength = isVertical ? bottom - top - paddingBottom : right - left - paddingRight;
|
||||||
|
|
||||||
int rowOrColumn = 0;
|
int rowOrColumn = 0;
|
||||||
int count = this.getChildCount();
|
int count = this.getChildCount();
|
||||||
@@ -184,7 +184,7 @@ public class WrapLayout extends LayoutBase {
|
|||||||
int childWidth = CommonLayoutParams.getDesiredWidth(child);
|
int childWidth = CommonLayoutParams.getDesiredWidth(child);
|
||||||
int childHeight = CommonLayoutParams.getDesiredHeight(child);
|
int childHeight = CommonLayoutParams.getDesiredHeight(child);
|
||||||
|
|
||||||
int length = this._lenghts.get(rowOrColumn);
|
int length = this._lengths.get(rowOrColumn);
|
||||||
if (isVertical) {
|
if (isVertical) {
|
||||||
|
|
||||||
childWidth = length;
|
childWidth = length;
|
||||||
@@ -200,7 +200,7 @@ public class WrapLayout extends LayoutBase {
|
|||||||
rowOrColumn++;
|
rowOrColumn++;
|
||||||
|
|
||||||
// Take current column width.
|
// Take current column width.
|
||||||
childWidth = length = this._lenghts.get(rowOrColumn);
|
childWidth = length = this._lengths.get(rowOrColumn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -217,7 +217,7 @@ public class WrapLayout extends LayoutBase {
|
|||||||
rowOrColumn++;
|
rowOrColumn++;
|
||||||
|
|
||||||
// Take current row height.
|
// Take current row height.
|
||||||
childHeight = length = this._lenghts.get(rowOrColumn);
|
childHeight = length = this._lengths.get(rowOrColumn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user