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
macaronlover
Posts: 101
Registered: ‎01-06-2014
My Device: Q10
My Carrier: EE

Changing the background and foreground colours of title bar

Is there any way possible to change the background and foreground colours of title bar using hex colours of my choice?

Please use plain text.
BlackBerry Development Advisor (Retired)
erahnenfuehrer
Posts: 85
Registered: ‎05-25-2012
My Device: Limited Edition Z10
My Carrier: Bell

Re: Changing the background and foreground colours of title bar

Try the FreeForm titlebar:

 

https://developer.blackberry.com/native/reference/cascades/bb__cascades__titlebarkind.html

 

Page {
    titleBar: TitleBar {
        appearance: TitleBarAppearance.Plain
        kind: TitleBarKind.FreeForm
        kindProperties: FreeFormTitleBarKindProperties {
            Container {
                background: Color.create("#65800080")
                opacity: 1.0
                Label {
                    text: "My title"
                }
            }
            
        }
 
    }

 

Please use plain text.
Developer
macaronlover
Posts: 101
Registered: ‎01-06-2014
My Device: Q10
My Carrier: EE

Re: Changing the background and foreground colours of title bar

Thanks it works but what about aligning the text to look like this? Also can a button to the left be added too?

 

Title bar with buttons

Please use plain text.
BlackBerry Development Advisor
sabdelsayed
Posts: 249
Registered: ‎08-17-2012
My Device: BlackBerry Z10 and Q10
My Carrier: Bell

Re: Changing the background and foreground colours of title bar

Hi macaronlover,

 

To achieve a title bar looking like the one you are showing above, you can use the default title bar kind while defining a dismissAction and an acceptAction to the TitleBar control.

 

titleBar: TitleBar {
        title: "Add"
        visibility: ChromeVisibility.Default
        
        dismissAction: ActionItem {
            title: "Cancel"
            onTriggered: {
                //Close pate
            }
        }
        
        acceptAction: ActionItem {
            title: "Accept"
            onTriggered: {
                //Accept and close page
            }
        }

 Note however, you will no longer be able to customize the background colour of the TitleBar. If you desire to customize have both, then your only option is to use the FreeForm TitleBar and design your own container with two button (left and right) and a centered  label.

 

 

 

 

@SamarAbdelsayed

Did this answer your question? Please accept post as solution.
Please refrain from posting new questions in solved threads.
Found a bug? Report it using the Issue Tracker
Please use plain text.
Developer
macaronlover
Posts: 101
Registered: ‎01-06-2014
My Device: Q10
My Carrier: EE

Re: Changing the background and foreground colours of title bar

How can I change the background foreground colours of the button?

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

Re: Changing the background and foreground colours of title bar

[ Edited ]

You wouldn't be able to, you would need to use an ImageButton or write your own custom control with say a container or ImageView as the main control to mimick a button.


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
macaronlover
Posts: 101
Registered: ‎01-06-2014
My Device: Q10
My Carrier: EE

Re: Changing the background and foreground colours of title bar

Would BB10 users be able to swipe to go back?

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

Re: Changing the background and foreground colours of title bar

As long as you have peekEnabled then yes.


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.