info@thistimebd.com

Saturday 11th of May 11:51:13pm

fonts quirrel

package com.thistimebd.web.font;


import android.graphics.Typeface;

import android.support.v7.app.AppCompatActivity;

import android.os.Bundle;

import android.widget.TextView;


public class MainActivity extends AppCompatActivity {

    private TextView textView1, textView2;

    private Typeface typeface1, typeface2;


    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);


        textView1=(TextView) findViewById(R.id.text1ViewId);

        textView2=(TextView)findViewById(R.id.text2ViewId);


        typeface1=Typeface.createFromAsset(getAssets(),"font/Rubik_Bold.ttf");

        textView1.setTypeface(typeface1);


        typeface2=Typeface.createFromAsset(getAssets(),"font/Rubik_Italic.ttf");

        textView2.setTypeface(typeface2);


    }

}

========================================================================================

string.xml

-----------


<resources>

    <string name="app_name">Font</string>

    <string name="text1">Hellow i am text1</string>

    <string name="text2">Hellow i am text2</string>

</resources>

=========================================================================================

activity_main.xml

----------------



<?xml version="1.0" encoding="utf-8"?>

<LinearLayout 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"

    android:orientation="vertical"

    android:padding="10dp"

    tools:context="com.thistimebd.web.font.MainActivity">


    <TextView

        android:id="@+id/text1ViewId"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:text="@string/text1"

        android:textSize="20sp"

        android:layout_marginBottom="20dp"

        android:typeface="sans"

        />


    <TextView

        android:id="@+id/text2ViewId"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:text="@string/text2"

        android:textSize="20sp"

        />




</LinearLayout>