//通过TypeValue把50dp转化为像素值
mMenuLeftPadding = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 50, context.getResources().getDisplayMetrics());
说明:如果上面的COMPLEX_UNIT_DIP选择sp是把sp转化为px
//通过TypeValue把50dp转化为像素值
mMenuLeftPadding = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 50, context.getResources().getDisplayMetrics());
说明:如果上面的COMPLEX_UNIT_DIP选择sp是把sp转化为px