public class MainActivity extends Activity {
private TextView tvheight, tvwidth;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tvheight = (TextView) findViewById(R.id.textView1);
tvwidth = (TextView) findViewById(R.id.textView2);
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
int height = metrics.heightPixels;
int width = metrics.widthPixels;
tvheight.setText("Height --> " + String.valueOf(height));
tvwidth.setText(" Width --> " + String.valueOf(width));
}
}
No comments:
Post a Comment