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
Gerry_BB
Posts: 38
Registered: ‎12-06-2011
My Device: Playbook 64GB, Curve 9360, BB Z10 LE
Accepted Solution

How to vertically centre text in a Picker

Hi,

 

I have a custom picker and am not able to set the text to be centred. Here is my QML :

 

Picker {
            title: "Every"
            dataModel: XmlDataModel {
                source: "asset:///RecurrencePicker.xml"
            }
            pickerItemComponents: [
                PickerItemComponent {
                    type: "option"
                    content: Container {
                        verticalAlignment: VerticalAlignment.Fill

                        horizontalAlignment: HorizontalAlignment.Fill
                        Label {
                            verticalAlignment: VerticalAlignment.Center
                            horizontalAlignment: HorizontalAlignment.Center
                            text: pickerItemData.value.toString();
                        }
                    }
                },
                PickerItemComponent {
                    type: "value"
                    
                    content: Container {
                        verticalAlignment: VerticalAlignment.Fill
                        preferredHeight: 150
                        horizontalAlignment: HorizontalAlignment.Fill
                        Label {
                            
                            verticalAlignment: VerticalAlignment.Center
                            horizontalAlignment: HorizontalAlignment.Center
                            text: pickerItemData.num.toString();
                        }
                    }
                }
            ]
        }  

 I tried with and without setting preferred height on container and label, but it doesn't seem to work. 

 

Any ideas?

 

Gerry

Please use plain text.
Developer
BBSJdev
Posts: 6,116
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30

Re: How to vertically centre text in a Picker

Set the container to a DockLayout.


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Please use plain text.
Developer
Gerry_BB
Posts: 38
Registered: ‎12-06-2011
My Device: Playbook 64GB, Curve 9360, BB Z10 LE

Re: How to vertically centre text in a Picker

Single line answer that works! I like it :smileyhappy:
Please use plain text.