Long text truncated on Xamarin.Forms iOS

Satoshi Fujimura 21 Reputation points
2021-02-28T16:33:41.227+00:00

I'm a beginner of Xamarin.Forms. I started from the empty project of Visual Studio 2019 containing MainPage.xml with some sample sentences.
When I just add two sentences to one of Labels, its iOS build truncated some words of the sentence. Android build is fine. Why? How to show entire sentences in iOS?

<?xml version="1.0" encoding="utf-8" ?>  
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"  
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"  
             x:Class="TestApp1.MainPage">  
  
    <StackLayout>  
        <Frame BackgroundColor="#2196F3" Padding="24" CornerRadius="0">  
            <Label Text="Welcome to Xamarin.Forms!" HorizontalTextAlignment="Center" TextColor="White" FontSize="36"/>  
        </Frame>  
        <Label Text="Start developing now" FontSize="Title" Padding="30,10,30,10"/>  
        <Label Text="Make changes to your XAML file and save to see your UI update in the running app with XAML Hot Reload. Give it a try! Maurice Maeterlinck was born in Ghent, Belgium, August 29, 1862. Although trained for the practice of the law and moderately successful in it, he very early became dissatisfied with the prospect of a career at the bar. " FontSize="16" Padding="30,0,30,0"/>  
        <Label FontSize="16" Padding="30,24,30,0">  
            <Label.FormattedText>  
                <FormattedString>  
                    <FormattedString.Spans>  
                        <Span Text="Learn more at "/>  
                        <Span Text="https://aka.ms/xamarin-quickstart" FontAttributes="Bold"/>  
                    </FormattedString.Spans>  
                </FormattedString>  
            </Label.FormattedText>  
        </Label>  
    </StackLayout>  
  
</ContentPage>  

72718-screenshot993.png

72719-screenshot994.png

Microsoft Visual Studio Community 2019 Version 16.8.6
Xamarin 16.8.000.262 (d16-8@4d60f9c)
Xamarin Designer 16.8.0.507 (remotes/origin/d16-8@e87b24884)
Xamarin Templates 16.8.112 (86385a3)
Xamarin.Android SDK 11.1.0.26 (d16-8/a36ce73)
Xamarin.iOS and Xamarin.Mac SDK 14.10.0.4 (5a05865f6)

Developer technologies | .NET | Xamarin
0 comments No comments
{count} votes

Accepted answer
  1. Anonymous
    2021-03-01T06:25:54.077+00:00

    Hello,​

    Welcome to our Microsoft Q&A platform!

    You can change Padding="30,0,30,0" to Margin="30,0,30,0" for the Label that contains long text. And I change Margin="30,24,30,0" for the url's label.

       <StackLayout>  
               <Frame BackgroundColor="#2196F3" Padding="24" CornerRadius="0">  
                   <Label Text="Welcome to Xamarin.Forms!" HorizontalTextAlignment="Center" TextColor="White" FontSize="36"/>  
               </Frame>  
               <Label Text="Start developing now" FontSize="Title" Padding="30,10,30,10"/>  
               <Label Text="Make changes to your XAML file and save to see your UI update in the running app with XAML Hot Reload. Give it a try! Maurice Maeterlinck was born in Ghent, Belgium, August 29, 1862. Although trained for the practice of the law and moderately successful in it, he very early became dissatisfied with the prospect of a career at the bar."   
                      FontSize="16"   
                      Margin="30,0,30,0"/>  
               <Label FontSize="16" Margin="30,24,30,0">  
                   <Label.FormattedText>  
                       <FormattedString>  
                           <FormattedString.Spans>  
                               <Span Text="Learn more at "/>  
                               <Span Text="https://aka.ms/xamarin-quickstart" FontAttributes="Bold"/>  
                           </FormattedString.Spans>  
                       </FormattedString>  
                   </Label.FormattedText>  
               </Label>  
           </StackLayout>  
    

    Here is running screenshot.

    72824-image.png

    If you want to know more details about padding and margin, here is an article about it.

    https://learn.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/layouts/margin-and-padding

    Best Regards,

    Leon Lu


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.