简体   繁体   中英

Element font-family is not allowed here anymore : Android Studio

I get the error mentioned in the title whenever I try to include a font in my XML. Here's the XML code.

    <?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".home_screen">

    <font-family>
        <font>

        </font>
    </font-family>

    <EditText
        android:id="@+id/title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="10"
        android:gravity="center"
        android:inputType="textPersonName"
        android:singleLine="true"
        android:text="HOME ACTIVATOR"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.503"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.03" />
</android.support.constraint.ConstraintLayout>

When I hover over the "font-family" tags, I see the issue pointed out by android studio. Documentation error maybe? I am following the online guide form the official google developers page here - https://developer.android.com/guide/topics/resources/font-resource

这个问题刚刚解决,看起来我使用的是API级别22,当时只能在API级别26中使用。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM