Android获取屏幕尺寸大小代码实例
发布时间:2016-12-28 来源:查字典编辑
摘要:@OverrideprotectedvoidonCreate(BundlesavedInstanceState){super.onCreat...
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //获取屏幕的长度和宽度 DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm); int width = dm.widthPixels; int heigh = dm.heightPixels; Dialog d = new Dialog(this); d.setTitle(width + "*" + heigh); d.show(); }