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
jayvd
Posts: 188
Registered: ‎04-07-2013
My Device: BlackBerry Z10

Add Drop Shadow to ImageView

Hi, how do we add drop shadow to Label and ImageView?

Thanksss
jayvdiyk.com
Developer
Zmey
Posts: 1,512
Registered: ‎12-18-2012
My Device: PlayBook, Z10, DAC

Re: Add Drop Shadow to ImageView

I don't think it's supported directly, but you can place one label on top of another using absolute layout:

 

// Default empty project template
import bb.cascades 1.0

// creates one page with a label

Page {
    property string myText: "A multiline label\nwith shadow"
    Container {
        // Main container with stack layout
        
        // Label with shadow (probably can be moved into a separate QML file as reusable control)
        Container {
            background: Color.Yellow
            layout: AbsoluteLayout {
            }
            Label {
                text: myText
                multiline: true
                textStyle.fontSize: FontSize.XLarge
                textStyle.color: Color.Gray
                layoutProperties: AbsoluteLayoutProperties {
                    positionX: labelLayout.layoutFrame.x + 3
                    positionY: labelLayout.layoutFrame.y + 3
                }
            }
            Label {
                text: myText
                multiline: true
                textStyle.fontSize: FontSize.XLarge
                attachedObjects: LayoutUpdateHandler {
                    id: labelLayout
                }
            }
        }
        
        Button {
            text: "Button to test positioning"
        }
    }
}

 This produces the following:

 

 

For ImageView you can place a Container with background under ImageView using the same technique.


Andrey Fidrya, @zmeyc on twitter
Developer
jayvd
Posts: 188
Registered: ‎04-07-2013
My Device: BlackBerry Z10

Re: Add Drop Shadow to ImageView

Its a great workaround, but drop shadows usually has a blurry effect.

I have to use this solution if I couldnt a way to blur it.

Thanks though
jayvdiyk.com