0
My font is not changing, the font file font1.ttf 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>
Is the file in a folder? e. g: Assets/fonts/...
– itscorey
No, it’s on the Assets, and the Assets I created in the app folder is right ?
– Paiva
http://prntscr.com/eo1py0 looks like this? Ignore the "Kotlin" folder, yours will look like "Java"... Anyway, it looks like this?
– itscorey
Error appears in logcat?
– itscorey