当前位置: 代码迷 >> Android >> android获取组件分寸
  详细解决方案

android获取组件分寸

热度:92   发布时间:2016-05-01 11:13:02.0
android获取组件尺寸
/**
* 获取组件高度(宽度)
*
* @param view
* @return
*/
public static int getHeight(View view)
{
int w = View.MeasureSpec.makeMeasureSpec(0,
View.MeasureSpec.UNSPECIFIED);
int h = View.MeasureSpec.makeMeasureSpec(0,
View.MeasureSpec.UNSPECIFIED);
view.measure(w, h);
return view.getMeasuredHeight();
}
  相关解决方案