Dilroop Singh
Dilroop Singh

Reputation: 544

How to get AttributeSet object from a View?

i have a initialised View as

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

i want to pass this view to a method say METHOD(View v) which later need the AttributeSet

i have to re-pass the values after i already defined as.

Method(View v , int Width , int height)

Is there any way to get AttributeSet object from view .

v.getWidth(); and v.getHeight(); are not working.

Upvotes: 1

Views: 2823

Answers (1)

Antonio E.
Antonio E.

Reputation: 4391

You should really take a look at the android documentation.

To retrieve that value you can either retrieve the LayoutParams you set OR, if the view has been already laid out you can retrieve them by using getMeasuredHeight or getMeasuredWidth

Upvotes: 2

Related Questions