可以在API 10 Android中使用resolveSizeAndState的最佳方法是什么?
我到处搜寻并且卡住了。
我已经将src代码重新编写了,无论如何它都可以工作,但是安全吗?
private int resolveSizeAndState2(int size, int measureSpec, int childMeasuredState) {
int result = size;
int specMode = MeasureSpec.getMode(measureSpec);
int specSize = MeasureSpec.getSize(measureSpec);
switch (specMode) {
case MeasureSpec.UNSPECIFIED:
result = size;
break;
case MeasureSpec.AT_MOST:
if (specSize < size) {
result = specSize | MEASURED_STATE_TOO_SMALL;
} else {
result = size;
}
break;
case MeasureSpec.EXACTLY:
result = specSize;
break;
}
return result | (childMeasuredState&MEASURED_STATE_MASK);
}
最佳答案
使用
ViewCompat.resolveSizeAndState()
应该管用
关于android - 替换为API 10的resolveSizeAndState吗?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/18865528/