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
Highlighted
Developer
Posts: 38
Registered: ‎12-06-2011
My Device: Playbook 64GB, Curve 9360, BB Z10 LE
My Carrier: Koodo
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

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

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. Smiley Happy

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

Re: How to vertically centre text in a Picker

Single line answer that works! I like it Smiley Happy