Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
dbigham
Posts: 554
Registered: ‎04-01-2009
My Device: Z10, PlayBook
Accepted Solution

DockLayout + leftMargin/topMargin

The following QML is intended to display an image in the top left corner, but to put 20 pixels of padding to the left and above the image.

 

Unfortunately, the margins seem to be ignored. Why?

 

import bb.cascades 1.0

Page {
    id: mainPage
    content: Container {
        layout: DockLayout {}
        ImageView {
            layoutProperties: DockLayoutProperties {
                horizontalAlignment: HorizontalAlignment.Left
                verticalAlignment: VerticalAlignment.Top
            }
            imageSource: "asset:///images/mom_text.png"
            leftMargin: 20
            topMargin: 20
        }
    }
}
Retired
gbeukeboom
Posts: 2,559
Registered: ‎10-16-2009
My Device: BlackBerry Z10

Re: DockLayout + leftMargin/topMargin

Margins will collapse at the edges, instead try adding padding to the Container:

https://developer.blackberry.com/cascades/documentation/ui/layouts/index.html

Garett
@garettBeuk
--
Goodbye everybody!
Developer
dbigham
Posts: 554
Registered: ‎04-01-2009
My Device: Z10, PlayBook

Re: DockLayout + leftMargin/topMargin

Thanks.

 

I had tried topPadding and leftPadding, but had added those attributes to the ImageView rather than the container and it of course didn't work.

 

The reason I was thrown off is that topMargin and leftMargin do apply to the ImageView, and so I thought padding worked the same.