【问题标题】:Why message text in Acr.UserDialogs toast displaced to bottom (Android)为什么 Acr.UserDialogs 中的消息文本移位到底部(Android)
【发布时间】:2021-08-31 22:59:57
【问题描述】:

我使用 Acr.UserDialogs 库在我的 Xamarin Android 项目中显示 toast。 当我同时使用图标和操作按钮时,消息文本被移到底部

我该如何解决?

【问题讨论】:

    标签: android xamarin


    【解决方案1】:

    你可以看看Acr.UserDialogshttps://github.com/aritchie/userdialogs/blob/45d4842648fdb01686e7493131cae66c30bcc975/src/Acr.UserDialogs/Platforms/Android/UserDialogsImpl.cs#L189的源码

    sb.SetSpan(new ImageSpan(drawable, SpanAlign.Bottom), 0, 1, SpanTypes.ExclusiveExclusive);
    

    这表示图片与文字底部对齐,所以当图片高于文字时,会显得文字向下倾斜。

    如果要让它们垂直居中,则需要修改,显然不行。

    所以你可以考虑自己写Snackbar来实现这个效果,参考它的源码https://github.com/aritchie/userdialogs/blob/45d4842648fdb01686e7493131cae66c30bcc975/src/Acr.UserDialogs/Platforms/Android/UserDialogsImpl.cs#L124

    【讨论】:

    • 朱你救了我的命,谢谢你!
    猜你喜欢
    • 2021-10-14
    • 2011-10-14
    • 2021-01-30
    • 2011-11-12
    • 1970-01-01
    • 2017-04-21
    • 2011-10-12
    • 2021-12-13
    • 1970-01-01
    相关资源
    最近更新 更多