Reputation: 445
Hi i am creating one custom dialog box. It's working fine. I am allocated to the width is
fill_parentand height is
wrap_contentHow to find out their width and height at runtime.
Upvotes: 4
Views: 4149
Reputation:
Try this;
AlertDialog.Builder a = new AlertDialog.Builder(this);
View v = a.create().getCurrentFocus();
v.measure(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
int height = v.getMeasuredHeight();
int width = v.getMeasuredWidth();
Upvotes: 1
Reputation: 3288
For any view, you can use getHeight() and getWidth() methods to get height and width information.
See this for more information.
Upvotes: 2