首页 > 代码库 > setWidth()和setHeight()没反应的问题,onCreate()里面获取控件的高度是0

setWidth()和setHeight()没反应的问题,onCreate()里面获取控件的高度是0

    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();   

 

setWidth()和setHeight()没反应的问题,onCreate()里面获取控件的高度是0