开发者

How do I get the height of a GWT object in pixels?

How do I get the height of a GWT object in pixels? I am trying to find a getHeig开发者_如何学运维ht method or something similar..


You are probably looking for getOffsetHeight() (inherited by every part of the UI from UiObject):

Gets the object's offset height in pixels. This is the total height of the object, including decorations such as border, margin, and padding.

There's also the getClientHeight() from Element:

Returns the inner height of an element in pixels, including padding but not the horizontal scrollbar height, border, or margin.

You can access the underlying Element of every UiObject (meaning Widgets, etc) via the getElement() method.

Be sure to check that the item is visible at the time the size is read, else you will get 0.


There is indeed getOffsetHeight() but that just gives the total height of the object, including decorations such as border and padding, but not margin.1 You can get the element and use getClientHeight() and it gives the inner height of an element in pixels, including padding but not the horizontal scrollbar height, border, or margin.

So getting the full rendered height including margins don't seem to be possible.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜