Typeface does not change font

0

My font is not changing, the font1.ttf font file is in the assets folder

Class

package br.com.paivasdev.fazendocafe;

import android.graphics.Typeface;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;

import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;

public class Passo8Activity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.passo8);

    TextView txt = (TextView) findViewById(R.id.texto_fonte);
    Typeface font = Typeface.createFromAsset(getAssets(), "font1.ttf");
    txt.setTypeface(font);

XML

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">


<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="TesteFonte"
    android:id="@+id/texto_fonte"
    android:textSize="50sp"
    android:layout_alignParentTop="true"
    android:layout_marginLeft="53dp"
    android:layout_marginStart="53dp"
    android:layout_marginTop="217dp" />



    </RelativeLayout>
    
asked by anonymous 24.03.2017 / 17:11

1 answer

0

You must have created the assets folder in the wrong place.

Change the view of your android project to project :

Theninserttheassetsfolderintothemainfolder(yourapp/app/src/main/assets):

    
25.03.2017 / 00:39