Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Center Canvas horizontally and vertically in a Layout

    Hello,

    I have a container (let's say a HLayout) and any Canvas (let's say a Button). I want to center the Button horizontally and vertically in the container. How can I accomplish this?
    I've tried several combinations of setting the layoutAlign() of both the container and the button, but to no avail.


    Is there a manual or tutorial on how to properly use the following elements:

    VerticalAlignment, Alignment, setAlign(), setLayoutAlign()?

    Unfortunately, the javadoc is not sufficient for me. For instance, it says for Layout.setAlign():

    Code:
    Alignment of all members in this Layout on the length axis. Defaults to "top" for vertical Layouts, and "left" for horizontal Layouts.
    However, the following code:
    Code:
    testHLayout.setAlign(Alignment.CENTER)
    Does NOT align the layout members horizontally centered as expected. In fact, nothing happens.
    setLeft() and setTop() are useless for me because these methods only accept pixel values (in original CSS, it's also possible to specify percentage values, e.g. left: 50%; and top: 50%; center an element in its container, but I think it won't work in SmartGWT since it calculates with pixel values only?)

    Any help would be greatly appreciated.
    Last edited by jballh; 7 Apr 2009, 01:30.

    #2
    I already explained how this can be achieved over here:
    http://forums.smartclient.com/showthread.php?t=3926

    Note that from my last post in that topic you could even have dynamic width if you use addDrawHandler to components and getVisibleWidth/Height

    Comment


      #3
      Hello mihai007,

      thank you very much. I've replied to your post in the other thread.

      Comment

      Working...
      X