Shahoud Al-Rai
Shahoud Al-Rai

Reputation: 167

Strange behavior with label span and italic font attribute

trying to follow Xamarin tutorial for a label view at : Label Tutorial

when applying italic font attribute in a span tag , while setting the size of the label text to any value in the label tag. the text size did not get applied to the text in the span with italic attribute.

<StackLayout Margin="20,35,20,25">
    <Label FontSize="50" TextColor="Blue">
        <Label.FormattedText>
            <FormattedString>
                <Span Text="underlined text" TextDecorations="Underline" />
                <Span Text=", emphasized" FontAttributes="Italic" />
            </FormattedString>
        </Label.FormattedText>
    </Label>
</StackLayout>

output from android emulator

Upvotes: 2

Views: 387

Answers (1)

Junior Jiang
Junior Jiang

Reputation: 12723

I also found that it when the span with Italic attribute the FontSize of Label can not work. However , I found a WorkAround for this , you can set FontSize of this Span to solve it .

Have a look at follow code:

<StackLayout Margin="20,35,20,25">
    <Label FontSize="50" TextColor="Blue">
        <Label.FormattedText>
            <FormattedString>
                <Span Text="underlined text" TextDecorations="Underline" />
                <Span Text=", emphasized" FontSize="50" FontAttributes="Italic" />
            </FormattedString>
        </Label.FormattedText>
    </Label>
</StackLayout>

The effect :

enter image description here

I think next version of Xamarin Forms will fix it as soon as possible .

Upvotes: 4

Related Questions