【问题标题】:How to change label to layout as same as show Notification on Xamarin Forms?如何将标签更改为与在 Xamarin 表单上显示通知相同的布局?
【发布时间】:2019-05-23 10:33:51
【问题描述】:

我在屏幕上显示label,但label 的字符串太长,它隐藏了我屏幕的一部分。我想自定义或替换 label 以与 Local Notifications (https://docs.microsoft.com/en-us/xamarin/android/app-fundamentals/notifications/local-notifications#expanded-layouts) 相同的布局

如何使用“...”将long string 折叠为short string

我正在使用 Xamarin Forms 3.4 版。

请帮帮我!谢谢!

【问题讨论】:

    标签: c# xamarin xamarin.forms xamarin.ios xamarin.android


    【解决方案1】:

    你可以使用标签like的LineBreakMode属性。

    var lblDetail = new Label
        {
            LineBreakMode = LineBreakMode.TailTruncation,
            Text = "a really long string that should show 2 lines then ..."
        };
    

    【讨论】:

    • 怎么知道string.Lengthstring.Length more)。
    • @HuuBaoNguyen 多长?你只需要使用 lblDetail.Length 来访问它
    • Label上显示的文本的长度,如何知道它的长度
    猜你喜欢
    • 1970-01-01
    • 2013-08-24
    • 1970-01-01
    • 2020-02-07
    • 1970-01-01
    • 1970-01-01
    • 2020-12-25
    • 2019-04-17
    • 1970-01-01
    相关资源
    最近更新 更多