stud91
stud91

Reputation: 1854

android:fontFamily not recognized in Android Studio

I am trying to implement the Dialog tutorial on Android developer website (http://developer.android.com/guide/topics/ui/dialogs.html) using Android Studio on Mac OSX. Everything is fine except for the font of the hint. Here is a picture below in the Design View:

enter image description here

I am unable to run it on my device as i get the following error:

Gradle: No resource identifier found for attribute 'fontFamily' in package 'android'

Here is the xml code which is the same as on the developer's website

<TextView
    android:layout_height="match_parent"
    android:layout_width="match_parent"
    android:text="ID"
    android:textSize="8pt"
    android:textColor="#000000"
    />
<EditText
    android:id="@+id/username"
    android:inputType="text"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="4dp"
    android:layout_marginLeft="4dp"
    android:layout_marginRight="4dp"
    android:layout_marginBottom="4dp"
    android:hint="enter your username"
/>
<TextView
    android:layout_height="match_parent"
    android:layout_width="match_parent"
    android:text="PIN"
    android:textSize="8pt"
    android:textColor="#000000"/>
<EditText
    android:id="@+id/password"
    android:inputType="textPassword"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="4dp"
    android:layout_marginLeft="4dp"
    android:layout_marginRight="4dp"
    android:layout_marginBottom="16dp"
    android:fontFamily="sans-serif"
    android:hint="enter your password" />

Upvotes: 1

Views: 940

Answers (1)

frogatto
frogatto

Reputation: 29285

In Android you should use android:typeface="serif" instead.

Android on itself only has 3 default fonts:

  • normal (Droid Sans)
  • serif (Droid Serif)
  • monospace (Droid Sans Mono)

Upvotes: 1

Related Questions