如何从View中获取AttributeSet对象?

时间:2014-04-10 15:34:32

标签: android view

我有一个初始化的视图

View v = new View (this); 
v.setLayoutParams(new LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.WRAP_CONTENT ));

我想将此视图传递给稍后需要AttributeSet

的方法METHOD(View v)

我必须在我已经定义为。

之后重新传递这些值
Method(View v , int Width , int height)

有没有办法从视图中获取AttributeSet对象。

v.getWidth();v.getHeight();无效。

1 个答案:

答案 0 :(得分:1)

你应该take a look at the android documentation

要检索该值,您可以检索您设置的LayoutParams,如果视图已经布局,您可以使用getMeasuredHeightgetMeasuredWidth

检索它们
相关问题