android获取屏幕的高度和宽度用到WindowManager这个类,两种方法:
1、WindowManager wm = (WindowManager) getContext()
2、WindowManager wm = this.getWindowManager();
// 动态设置imageview的宽高
-
image
= (ImageView)findViewById(R.id.ImageView01); -
//height = image.getHeight(); -
//width = image.getWidth(); -
//Log.d(TAG, "height: " + height); -
//Log.d(TAG, "width: " + width); -
-
-
LayoutParams para; -
para = image.getLayoutParams(); -
-
para.height = 300; -
para.width = 300; -
image.setLayoutParams(para);