Android 代码获取手机屏幕分辨率的代码

@Override
         public void onCreate(Bundle savedInstanceState) {
                 super.onCreate(savedInstanceState);
                setContentView(R.layout.main);
                DisplayMetrics displayMetrics = new DisplayMetrics();
                getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
                String string = "屏幕分辨率为:"+displayMetrics.widthPixels+ "×"+displayMetrics.heightPixels;
                textView = (TextView) findViewById(R.id.textView1);
                textView.setText(string);
        }

本文出自 “Android的一点一滴” 博客,请务必保留此出处http://haiyuanxi.blog.51cto.com/4230602/1009208

你可能感兴趣的:(android,代码获取手机屏幕分辨率)