首页 > 系统 > Android > 正文

android获取屏幕像素思路及代码

2020-04-11 12:29:49
字体:
来源:转载
供稿:网友
复制代码 代码如下:

<SPAN style="FONT-SIZE: 18px">private void alertScreenDialog() {
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
String optStr = "手机屏幕分辨率为: "+dm.widthPixels+" x "+dm.heightPixels;
Builder builder = new Builder(this);
builder.setMessage(optStr);
builder.setIcon(R.drawable.firefox);
builder.setTitle("获取屏幕像素");
//点击确定按钮
builder.setPositiveButton("确定", new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(GetScreenActivity.this, "获取到像素", Toast.LENGTH_LONG).show();
}
});
builder.setNegativeButton("返回", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(GetScreenActivity.this, "返回", Toast.LENGTH_LONG).show();
}
});
builder.create().show();
}</SPAN>
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表