Maui android text inside label property element

Haviv Elbsz 2,091 Reputation points
2023-12-12T19:06:07.6066667+00:00

I use version 17.9 preview and android version 34. Hello all. how I know where to start the text in the xaml file in relation to the start text in the output. For example the text below is the text 'First line' starts in most left in the output . And if I want to indent the text how I know where is left limit of the text when it's outputs. in other words I expect to have some mark in xaml file that shows me where the text starts. Thank you very much

                             
<Label>
    <Label.Text>
        First line
        Second line
    </Label.Text>
</Label>
Developer technologies | .NET | .NET MAUI
0 comments No comments
{count} votes

Accepted answer
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 50,131 Reputation points Microsoft External Staff
    2023-12-13T02:24:40.42+00:00

    Hello,

    For the left limit of the MAUI text start, you could set the background color for the Label to see it.

    For the code you provide, the first line will be topped and the second line will be offset a lot after compilation. This is because when using <Text> tags, VS treats the entire piece of text from the first character to the last character as a string.

    In other words, the second line actually contains many spaces in front of it.

    If you remove the spaces before the second line, you will find that both lines start at the same location.

                <Label>
    
                    <Label.Text>
                        first line
    second line
                    </Label.Text>
                </Label>
                ```
    
    Best Regards,
    
    Alec Liu.
    
    *************************************************************************
    
    If the answer is the right solution, please click "**Accept Answer**" and kindly upvote it. If you have extra questions about this answer, please click "Comment". 
    
    **Note: Please follow the steps in our [documentation][1] to enable e-mail notifications if you want to receive the related email notification for this thread.**
    
    
    
    
    
      [1]: https://docs.microsoft.com/en-us/answers/articles/67444/email-notifications.html
    
    
    0 comments No comments

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.