Android获取屏幕尺寸

获取屏幕宽高尺寸的代码示例

public void getScreenSize(Context context){
	WindowManager manager = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
	
	DisplayMetrics dm=new DisplayMetrics();
	manager.getDefaultDisplay().getMetrics(dm);
	int width=dm.widthPixels;
	int height=dm.heightPixels;
	log.debug("屏幕宽:", String.valueOf(width));
	log.debug("屏幕高:", String.valueOf(height));
}


你可能感兴趣的:(android)