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

转载自: 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());
	}


你可能感兴趣的:(Android根据分辨率进行单位转换-(dp,sp转像素px))