Aligning text centrally within a button | developer.brewmp.com Aligning text centrally within a button | developer.brewmp.com

Developer

Aligning text centrally within a button

Forums:

I have a wide button, covering most of the screen width, on the very far left of the button is a small image and then I want some text to be displayed which is centered horizontally.

The button is created as a button widget which is decorating an image static widget.

 

I'm calling IWidget_SetFlags(piwButton, IDF_ALIGN_MIDDLE | IDF_ALIGN_CENTER) to center the text both horizontally and vertically within the button (if I don't call this the text is being displayed immediatly to the right of the image).

However the text is centered not within the entire width of the button, but within the width of the button less the width of the image.

i.e. it looks like this (text is shifted over to the right and not central)

 

[image                text             ]

 

but I want it to look like this: (text is central)

 

[image             text                ]

 

What is the best way to align the text so its central to the button (and thus central to the screen)?

You can use IWidget_SetLeftPadding/IWidget_SetRightPadding on static widget portion of imagestatic widget to align text as per your requirements. Get static widget of imagestatic widget using IWidget_GetImageStaticStaticWidget.

You can use IWidget_SetLeftPadding/IWidget_SetRightPadding on static widget portion of imagestatic widget to align text as per your requirements. Get static widget of imagestatic widget using IWidget_GetImageStaticStaticWidget.