Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I need to have formatted text inside a Xamarin Forms button (two different sizes)

I have a Xamarin Forms project, and I need to have a custom button. The button would look something like this:

enter image description here

I assume I need to create a custom renderer, but I can't figure out how to have two different font sizes inside a button?

I need renderers for both Android and iOS. Any help would be greatly appreciated. Thanks!

like image 291
Mike Luken Avatar asked Oct 20 '25 12:10

Mike Luken


1 Answers

How about skipping the custom renderer and use a Frame w/ a tap gesture that encloses a formatted text Label:

<Frame VerticalOptions="Center" HorizontalOptions="Center" CornerRadius="10" BackgroundColor="Gray" BorderColor="Black">
    <Frame.GestureRecognizers>
        <TapGestureRecognizer Tapped="OnFrameTapped"/>
    </Frame.GestureRecognizers>
    <Label>
        <Label.FormattedText>
            <FormattedString>
                <Span Text="2" FontSize="30" />
                <Span Text="ABC" FontSize="15" />
            </FormattedString>
        </Label.FormattedText>
    </Label>
</Frame>

enter image description here

like image 196
SushiHangover Avatar answered Oct 23 '25 03:10

SushiHangover