现在的位置: 首页 > 综合 > 正文

Android根据分辨率进行单位转换-(dp,sp转像素px)

2018年02月04日 ⁄ 综合 ⁄ 共 362字 ⁄ 字号 评论关闭

转载自: http://my.oschina.net/muchenshou/blog/60814

	/**
	 * UnitConvertUtil.getRawSize(
					TypedValue.COMPLEX_UNIT_SP, TEXT_SIZE)
	 * */
	public static float getRawSize(int unit, float size) {
		Context c = MCloudApplication.getInstance();//application.context
		Resources r;

		if (c == null)
			r = Resources.getSystem();
		else
			r = c.getResources();

		return TypedValue.applyDimension(unit, size, r.getDisplayMetrics());
	}

抱歉!评论已关闭.