Android自定义view知识-view的测量模式

int widthMode = MeasureSpec.getMode(widthMeasureSpec);
int heightMode = MeasureSpec.getMode(heightMeasureSpec);
// 如果 widthMode == MeasureSpec.AT_MOST : 说明在布局中指定了是 wrap_content
// 如果 widthMode == MeasureSpec.EXACTLY : 说明在布局中指定了确切的值,如100dp 或 match_parent
// 如果 widthMode == MeasureSpec.UNSPECIFIED : 尽可能的大,一般很少能用到,
// ListView,ScrollView 在测量子布局的时候会用到 MeasureSpec.UNSPECIFIED

// widthMeasureSpec/heightMeasureSpec 会包含两个信息,第一个信息是模式:2位,第二个信息是宽度或高度:30位

猜你喜欢

转载自blog.csdn.net/qq_34829270/article/details/83476397