注释并未明确说明如何解决问题:
命名
受保护的方法无效 onMeasure ( int widthMeasureSpec , int heightMeasureSpec )
问题
概要值必须≥0且≤1073741823
这是lint抱怨的代码:
private int mMaxHeight = WITHOUT_MAX_HEIGHT_VALUE;
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
try {
int heightSize = MeasureSpec.getSize(heightMeasureSpec);
if (mMaxHeight != WITHOUT_MAX_HEIGHT_VALUE
&& heightSize > mMaxHeight) {
heightSize = mMaxHeight;
}
// First parameter of MeasureSpec.makeMeasureSpec has lint error
heightMeasureSpec = MeasureSpec.makeMeasureSpec(heightSize, MeasureSpec.AT_MOST);
//heightMeasureSpec = MeasureSpec.makeMeasureSpec(R.dimen.something, MeasureSpec.AT_MOST);
getLayoutParams().height = heightSize;
} catch (Exception e) {
Log.e("MaxHeightListView", "Error forcing height", e);
} finally {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}
heightSize
只是一个int值,也尝试使用资源维度(R.dimen.something),但问题仍然存在。