How to underline single words in a shortcut in Xamarin.Forms?

I would like to make underlined label text in Xamarin.Forms. I could not find a suitable solution for this. One thing I discovered is that there is no underline for text in Xamarin, so we could add BoxViewfor a line like this:

<StackLayout  Grid.Row="0" Padding="0" VerticalOptions="Center">
    <Label Text="Terms and Conditions" />
    <BoxView BackgroundColor="White" HeightRequest="1" Margin="0,-8,0,0" />
</StackLayout>

But this is also not a suitable solution, since it draws a line for everything StackView. I would like to emphasize only parts of the text, such as the word "Terms" in the code above.

+4
source share
1 answer

You can use Effects for this.

UnderlineEffect, :

Android

var tv = (TextView)Control;
tv.PaintFlags = tv.PaintFlags | PaintFlags.UnderlineText;

IOS

Mutable String, : fooobar.com/questions/75060/...

Edit

. : http://smstuebe.de/2016/08/29/underlinedlabel.xamarin.forms/

+15

Source: https://habr.com/ru/post/1652804/


All Articles