【问题标题】:Font set for custom label doesn't work in Android 8.0为自定义标签设置的字体在 Android 8.0 中不起作用
【发布时间】:2018-07-27 07:01:31
【问题描述】:

我有带有自定义渲染器的自定义标签。在渲染器(确切地说是重写的 OnElementChanged 方法)中,我正在设置 FontFamily 和 FontSize 等属性,如下所示: view.FontFamily = "Helvetica_Light_Normal.ttf#Helvetica_Light-Normal"; view.FontSize = 20; 然后我将文本设置为控制。 在 Android 7.1 (Nexus 6) 中它可以正常工作并且字体应用于标签,但在 Android 8.0 (Xiaomi Mi 6) 中它没有。我尝试了许多解决方案,例如在 xaml 中设置字体、针对特定平台等 - 只是我在互联网上能够找到的所有内容,但我没有选择和想法。

我能做些什么来完成这项工作?

【问题讨论】:

标签: android xamarin xamarin.android


【解决方案1】:

使用这条线

    <?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:android="http://schemas.android.com/apk/res/android">
    <font
        android:fontStyle="normal"
        android:fontWeight="400"
        android:font="@font/lobster_regular" />
    <font
        android:fontStyle="italic"
        android:fontWeight="400"
        android:font="@font/lobster_italic" />
</font-family>

正确阅读this链接中的所有详细信息

【讨论】:

  • 我可以在 Xamarin (xaml) 中应用这个吗?
猜你喜欢
  • 2015-04-23
  • 1970-01-01
  • 1970-01-01
  • 2012-10-04
  • 2012-11-27
  • 2013-02-24
  • 2015-11-29
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多