使用xml

时间:2018-06-13 19:01:24

标签: android xml xamarin fonts xamarin.android

我目前正在使用Xamarin NATIVE制作一个Android应用程序,而不是表单。我在让字体正常工作方面遇到了问题。我已尝试关注此链接here它似乎并不完整。

我一直在使用扩展程序XamarIDEA来完成Android Studio中的大部分UI工作,因为无论出于何种原因,我无法以稳定的方式在Visual Studio中加载.axml设计器。我的目标是能够引用字体文件(.otf格式)。我把我的.otf文件放在/ProjectRoot/Resources/font里面。然后我在这个font.xml文件中的这些字体(/ ProjectRoot / Resources / font)所在的目录中创建了一个font.xml文件,我有以下xml ..

<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto">

<font android:font="@font/mindburger_studio_bambino_new_bold"
      android:fontStyle="normal"
      android:fontWeight="700"
      app:font="@font/mindburger_studio_bambino_new_bold"
      app:fontStyle="normal"
      app:fontWeight="700"  />


</font-family>

我无法在TextView中引用此字体。这个字体根本就没有应用。

 <TextView
    android:id="@+id/textView4"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:fontFamily="@font/mindburger_studio_bambino_new"
    android:text="@string/todays_price"
    android:textAlignment="center"
    android:textColor="#ffffff"
    android:textSize="24sp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.25"
    tools:text="@string/todays_price" />

有没有人成功使用xml作为显示器在xamarin本机应用程序中使用自定义字体?我知道它可以通过代码实现,但通过代码实现这么多控件似乎很容易。

0 个答案:

没有答案
相关问题