Andriod xml中指定layout_height=16dp,但是得到的MODE是AT_MOST
if(widthMode!=MeasureSpec.EXACTLY){
desireWith=dp2px(100);
}else{
desireWith=widthSize;
}
if(heightMode!=MeasureSpec.EXACTLY){
desireHeight=dp2px(100);
}else{
desireHeight=heightSize;
}
Log.e("YUANJIZE","widthMode"+widthMode);
Log.e("YUANJIZE","heightMode"+heightMode);
<com.example.yuan.ringview.DianDianView
android:layout_below="@+id/cancle"
android:layout_width="300dp"
android:layout_height="300dp"
app:count="8"
app:firstcolor="@color/colorPrimaryDark"
app:secondcolor="@android:color/darker_gray"
app:distance="30"
app:paint_width="18dp"
app:bitmap="@mipmap/ic_launcher"
/>
结果:
getMeasuredHeight450
widthMode1073741824
heightMode-2147483648
widthMode1073741824
heightMode1073741824
第一次测量出来的值是-2147483648也就是AT_MOST,这是为什么?不是应该是EXACTLY吗?