android动态设置控件宽高,找了很多都不靠谱,这个是亲身尝试,可以正常设置
WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);ImageView image = (ImageView) findViewById(R.id.img);
image.setVisibility(View.VISIBLE);
int width = wm.getDefaultDisplay().getWidth();
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) image
.getLayoutParams();
params.width = width;
image.setLayoutParams(params);