Kodi Community Forum

Full Version: Label centering not working?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hi,

I'm trying to center a label within a list element which contains multiple labels, but the text isn't centered at all. Instead it's shifted outside the left position of the label. My current code:

Code:
<control type="list">
    <left>0</left>
    <top>0</top>
    <width>400</width>
    <height>400</height>
    <itemlayout width="400" height="100">
        <control type="label">
            <left>0</left>
            <top>0</top>
            <width>100</width>
            <height>100</height>
            <align>center</align>
            <aligny>center</aligny>
            <label>TEST</label>
            <textcolor>FFFFFFFF</textcolor>
            <font>font13</font>
        </control>
        <control type="label">
            <left>100</left>
            <top>0</top>
            <width>100</width>
            <height>100</height>
            <align>center</align>
            <aligny>center</aligny>
            <label>Title label</label>
            <textcolor>FFFFFFFF</textcolor>
            <font>font13</font>
        </control>
        <control type="label">
            <left>100</left>
            <top>50</top>
            <width>100</width>
            <height>100</height>
            <align>center</align>
            <aligny>center</aligny>
            <label>Subtitle label</label>
            <textcolor>FFFFFFFF</textcolor>
            <font>font13</font>
        </control>
    </itemlayout>
    <focusedlayout width="400" height="100">
        <control type="label">
            <left>0</left>
            <top>0</top>
            <width>100</width>
            <height>100</height>
            <align>center</align>
            <aligny>center</aligny>
            <label>TEST</label>
            <textcolor>FFFFFFFF</textcolor>
            <font>font13</font>
        </control>
        <control type="label">
            <left>100</left>
            <top>0</top>
            <width>100</width>
            <height>100</height>
            <align>center</align>
            <aligny>center</aligny>
            <label>Title label</label>
            <textcolor>FFFFFFFF</textcolor>
            <font>font13</font>
        </control>
        <control type="label">
            <left>100</left>
            <top>50</top>
            <width>100</width>
            <height>100</height>
            <align>center</align>
            <aligny>center</aligny>
            <label>Subtitle label</label>
            <textcolor>FFFFFFFF</textcolor>
            <font>font13</font>
        </control>
    </focusedlayout>
</control>

Expected behavior:
1 Item with centered text (horizontal and vertical)
2 Text items right from the centered item

Can't get this to work - any ideas?
I managed to get it to work using the following technique:
Set <left> or <posx> to half of <width>

Is this intended behavior? Huh
What are you seeing? Perhaps a screenshot?

EDIT: Ah, you're probably using Frodo. Gotham is needed for <left>
Nope, running latest Gotham nightly. Even Confluence is using the left = width/2 workaround and it happens on all Gotham nightlies. As far as I can tell this isn't a problem of a specific nightly build.

I made a small mockup of the problem:
Image
Check your Defaults.xml doesn't have any positions/dimensions in it.
Defaults.xml is empty
Okay… just for explanation… here's my complete LoginScreen.xml

Nothing spectacular here… just a list for the profiles to show up. Setup different profiles, paste the code from below into LoginScreen.xml from Confluence skin folder and start XBMC.

Code:
<?xml version="1.0" encoding="UTF-8"?>
<window>
    <backgroundcolor>FFFF0000</backgroundcolor>
    <defaultcontrol always="true">52</defaultcontrol>
    <allowoverlay>no</allowoverlay>
    <coordinates>
        <system>1</system>
        <left>0</left>
        <top>0</top>
    </coordinates>
    <controls>
        <control type="group">
            <width>960</width>
            <height>600</height>
            <top>240</top>
            <left>480</left>
            <control type="list" id="52">
                <top>0</top>
                <left>0</left>
                <width>960</width>
                <height>500</height>
                <onup>52</onup>
                <ondown>52</ondown>
                <scrolltime>200</scrolltime>
                <viewtype label="535">list</viewtype>
                <itemlayout width="960" height="200">
                    <control type="label">
                        <left>0</left>
                        <top>0</top>
                        <width>200</width>
                        <height>200</height>
                        <font>font13</font>
                        <textcolor>FFFFFFFF</textcolor>
                        <align>center</align>
                        <aligny>center</aligny>
                        <label>Test</label>
                    </control>
                    <control type="label">
                        <left>200</left>
                        <top>0</top>
                        <width>400</width>
                        <height>200</height>
                        <font>font13</font>
                        <textcolor>FFFFFFFF</textcolor>
                        <align>left</align>
                        <label>$INFO[ListItem.Label]</label>
                    </control>
                </itemlayout>
                <focusedlayout width="960" height="200">
                    <control type="label">
                        <left>0</left>
                        <top>0</top>
                        <width>200</width>
                        <height>200</height>
                        <font>font13</font>
                        <textcolor>FFFFFFFF</textcolor>
                        <align>center</align>
                        <aligny>center</aligny>
                        <label>Test</label>
                    </control>
                    <control type="label">
                        <left>200</left>
                        <top>0</top>
                        <width>400</width>
                        <height>200</height>
                        <font>font13</font>
                        <textcolor>FFFFFFFF</textcolor>
                        <align>left</align>
                        <label>$INFO[ListItem.Label]</label>
                    </control>
                </focusedlayout>
            </control>
        </control>
    </controls>
</window>

And as I mentioned a few posts above: Confluence is using the
Code:
left = width/2
technique on the main menu as well… seems strange to me using a centering text and still need to set the left position to half the width of the control…
it's always been like that for labels inside lists afaik.
(2014-03-04, 00:46)ronie Wrote: [ -> ]it's always been like that for labels inside lists afaik.
Thanks… didn't knew that. This should be mentioned somewhere in the Wiki…
Someone should have told me when I changed the left/right stuff, huh? Smile

No big deal, plenty of time to change it after Gotham.

(Side note: I was under the impression that this was exactly the opposite. i.e. I thought that labels in lists ALWAYS responded correctly to the positioning stuff, and it was only labels outside of lists that had the definition of <posx> change based on the <align> type. Looking at the code it appears I was wrong, in that in the code it responds how I've said, but in the XML it was consistently 'wrong'?). Thus the reason I spent all that time fixing labels outside of lists to respond properly, without touching labels inside lists...

Jonathan
ah, there's so many bugs we haven't told you about ;-)

don't worry, one at a time... one at a time
Yeah no prob at all… but I think this should be fixed asap as text centering should only affect the text positioning inside a label not the label positioning itself.
It'll be fixed after Gotham. It's literally a matter of deleting a couple lines. There's even a TODO sitting there :p
(2014-03-04, 22:21)jmarshall Wrote: [ -> ]It'll be fixed after Gotham. It's literally a matter of deleting a couple lines. There's even a TODO sitting there :p

Will the label centering be fixed in Helix?
Yes - there's a PR for it already. Search my PRs on github if you're interested in building yourself and testing.
Pages: 1 2