Android获取屏幕尺寸大小代码实例

@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();

}

以上是 Android获取屏幕尺寸大小代码实例 的全部内容, 来源链接: utcz.com/z/334316.html

回到顶部