1、Android手机的屏幕宽高度
WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
int width = wm.getDefaultDisplay().getWidth();
int height = wm.getDefaultDisplay().getHeight();
2、代码设置控件的高宽度
DisplayMetrics dm = getResources().getDisplayMetrics();
width = dm.widthPixels;
height = dm.heightPixels;
imageView=(ImageView)findViewById(R.id.imageView);//获取当前控件的对象
LinearLayout.LayoutParams params= (LinearLayout.LayoutParams) imageView.getLayoutParams();
params.height=width/2;//设置当前控件布局的高度
imageView.setLayoutParams(params);//将设置好的布局参数应用到控件中