Android获取屏幕大小(Px)

 1 private DisplayMetrics dm = new DisplayMetrics();
 2     TextView tv;
 3     Button bu;
 4     @Override
 5     protected void onCreate(Bundle savedInstanceState) {
 6         super.onCreate(savedInstanceState);
 7         setContentView(R.layout.activity_weather);
 8         tv = (TextView) findViewById(R.id.tv);
 9         bu = (Button) findViewById(R.id.but);
       //
10 getWindowManager().getDefaultDisplay().getMetrics(dm); 11 tv.setText(dm.widthPixels+"::"+dm.heightPixels); 12 }

 

posted @ 2015-07-23 09:37  liter7  阅读(268)  评论(0编辑  收藏  举报