editText=(EditText)findViewById(R.id.myEditText); // editText.setHeight(10); //不生效 editText.getLayoutParams().height = 100;
onCreate()里面获取控件的高度是0 解决办法
int w = View.MeasureSpec.makeMeasureSpec(0,View.MeasureSpec.UNSPECIFIED); int h = View.MeasureSpec.makeMeasureSpec(0,View.MeasureSpec.UNSPECIFIED); imageView.measure(w, h); int height =imageView.getMeasuredHeight(); int width =imageView.getMeasuredWidth();