PHPz2017-04-17 17:18:40
0.5 should ensure accuracy after rounding.
To convert to sp, you can refer to the FONT_SCALE attribute value in Settings.System to make corresponding adjustments.
迷茫2017-04-17 17:18:40
public static int sp2px(Context context, float spValue) {
final float scale = context.getResources().getDisplayMetrics().scaledDensity;
return (int) (spValue * scale + 0.5f);
}