下面列出了android.widget.AdapterView#LayoutParams ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
protected int measureChildrens(final boolean justMeasure) {
int row = 0;
int col = 0;
int rowHeight = 0;
int spansFilled = 0;
int fullHeight = mItemMargin;
for (int position = 0; position < mAdapter.getCount(); position++) {
View childView = getChildAt(position);
if (childView == null) {
childView = mAdapter.getView(position, null, this);
LayoutParams params = (LayoutParams) childView.getLayoutParams();
if (params == null) {
params = new LayoutParams(new AdapterView.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
}
if (!justMeasure) {
addViewInLayout(childView, NOT_DEFINED_VALUE, params);
}
}
final LayoutParams lp = (LayoutParams) childView.getLayoutParams();
measureChildren(childView, lp.width, lp.height);
lp.position = position;
spansFilled += lp.span;
while (true) {
if (spansFilled <= mColCount) {
lp.row = row;
lp.column = lp.span == mColCount ? LayoutParams.ALL_COLUMNS : col;
col = spansFilled;
if (justMeasure) {
fireCalculateChildrenPositionEvent(childView, lp.position, lp.row, lp.column);
} else {
childView.setLayoutParams(lp);
}
rowHeight = Math.max(rowHeight, mItemMargin + childView.getMeasuredHeight());
}
if (spansFilled >= mColCount) {
fullHeight += rowHeight;
row++;
col = 0;
rowHeight = 0;
if (spansFilled != mColCount) {
spansFilled = lp.span;
continue;
}
spansFilled = 0;
}
break;
}
}
fullHeight += rowHeight;
return fullHeight;
}
protected int measureChildrens(final boolean justMeasure) {
int row = 0;
int col = 0;
int rowHeight = 0;
int spansFilled = 0;
int fullHeight = mItemMargin;
for (int position = 0; position < mAdapter.getCount(); position++) {
View childView = getChildAt(position);
if (childView == null) {
childView = mAdapter.getView(position, null, this);
LayoutParams params = (LayoutParams) childView.getLayoutParams();
if (params == null) {
params = new LayoutParams(new AdapterView.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
}
if (!justMeasure) {
addViewInLayout(childView, NOT_DEFINED_VALUE, params);
}
}
final LayoutParams lp = (LayoutParams) childView.getLayoutParams();
measureChildren(childView, lp.width, lp.height);
lp.position = position;
spansFilled += lp.span;
while (true) {
if (spansFilled <= mColCount) {
lp.row = row;
lp.column = lp.span == mColCount ? LayoutParams.ALL_COLUMNS : col;
col = spansFilled;
if (justMeasure) {
fireCalculateChildrenPositionEvent(childView, lp.position, lp.row, lp.column);
} else {
childView.setLayoutParams(lp);
}
rowHeight = Math.max(rowHeight, mItemMargin + childView.getMeasuredHeight());
}
if (spansFilled >= mColCount) {
fullHeight += rowHeight;
row++;
col = 0;
rowHeight = 0;
if (spansFilled != mColCount) {
spansFilled = lp.span;
continue;
}
spansFilled = 0;
}
break;
}
}
fullHeight += rowHeight;
return fullHeight;
}
private int measureChildrens(final boolean justMeasure) {
int row = 0;
int col = 0;
int rowHeight = 0;
int spansFilled = 0;
int fullHeight = mItemMargin;
for (int position = 0; position < mAdapter.getCount(); position++) {
View childView = getChildAt(position);
if (childView == null) {
childView = mAdapter.getView(position, null, this);
LayoutParams params = (LayoutParams) childView.getLayoutParams();
if (params == null) {
params = new LayoutParams(new AdapterView.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
}
if (!justMeasure) {
addViewInLayout(childView, NOT_DEFINED_VALUE, params);
}
}
final LayoutParams lp = (LayoutParams) childView.getLayoutParams();
measureChildren(childView, lp.width, lp.height);
lp.position = position;
spansFilled += lp.span;
while (true) {
if (spansFilled <= mColCount) {
lp.row = row;
lp.column = lp.span == mColCount ? LayoutParams.ALL_COLUMNS : col;
col = spansFilled;
if (justMeasure) {
fireCalculateChildrenPositionEvent(childView, lp.position, lp.row, lp.column);
} else {
childView.setLayoutParams(lp);
}
rowHeight = Math.max(rowHeight, mItemMargin + childView.getMeasuredHeight());
}
if (spansFilled >= mColCount) {
fullHeight += rowHeight;
row++;
col = 0;
rowHeight = 0;
if (spansFilled != mColCount) {
spansFilled = lp.span;
continue;
}
spansFilled = 0;
}
break;
}
}
fullHeight += rowHeight;
return fullHeight;
}
public LayoutParams(AdapterView.LayoutParams other) {
super(other);
setupWidthAndHeight();
}
public LayoutParams(AdapterView.LayoutParams other) {
super(other);
setupWidthAndHeight();
}
public LayoutParams(AdapterView.LayoutParams other) {
super(other);
setupWidthAndHeight();
}