Android Studio Font Yazı tipi değiştirme

Android Studio Font Yazı tipi değiştirme

Öncelikle indirdiğimiz ttf uzantılı yazı fontlarımızı assets klasörü altında fonts klasörünün içine atıyoruz. Yoksa sağ tık new folder demeniz yeterli olucaktır.

Assest dosyasını ister res klasörünün dosya konumuna elle oluşturabilirsiniz. İsterseniz android studio içinden aşağıdaki yolları izleyerek oluşturabilirsiniz.

Oluşan assests dosyasına sağ tık ile bir directory içinde fonts klasörü oluşturun ve oneday.tff’i ben kendim için indirdim sizde kendinize özel tff’i indirip içine atınız.

İkinci iş Tasarım oluşturmak.. Edittext,textview ve button olayı şu. Edittext’e yazdığımız yazı buttona basıyoruz seçtiğimiz font’ta bize text viewde gösteriyor..

Xml Kodumuz:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:paddingBottom="@dimen/activity_vertical_margin"

android:paddingLeft="@dimen/activity_horizontal_margin"

android:paddingRight="@dimen/activity_horizontal_margin"

android:paddingTop="@dimen/activity_vertical_margin"

tools:context=".MainActivity" >

 

<Button

android:id="@+id/button1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignParentLeft="true"

android:layout_alignParentTop="true"

android:layout_marginLeft="36dp"

android:layout_marginTop="136dp"

android:text="Button" />

 

<TextView

android:id="@+id/textView1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignLeft="@+id/button1"

android:layout_alignParentTop="true"

android:layout_marginTop="79dp"

android:text="TextView" />

 

<EditText

android:id="@+id/editText1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignLeft="@+id/textView1"

android:layout_alignParentTop="true"

android:layout_marginTop="33dp"

android:ems="10" >

 

<requestFocus />

</EditText>

 

</RelativeLayout>

 

Javada ise tanımladık herşeyi, EditText.getText- Edittext’ten girdiğimiz karakterleri string tipinde al, ve textview.setText yaz..

Button’a basınca da t1.de font oneway.ttf ayarladığımız font olsun mantık bu 

Java Kodumuz:

 

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

package com.example.yazitipi;

 

import android.app.Activity;

import android.graphics.Typeface;

import android.os.Bundle;

import android.view.View;

import android.widget.Button;

import android.widget.EditText;

import android.widget.TextView;

 

public class MainActivity extends Activity {

Button b1;

EditText e1;

TextView t1;

Typeface tf1;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

e1=(EditText)findViewById(R.id.editText1);

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

b1=(Button)findViewById(R.id.button1);

tf1=Typeface.createFromAsset(getAssets(), "fonts/oneway.ttf");

b1.setOnClickListener(new View.OnClickListener() {

 

@Override

public void onClick(View v) {

t1.setText(e1.getText().toString());

t1.setTypeface(tf1);

}

});

}

 

 

Uygulamamızın Resimli hali : Üstteki editText’teki yazı ile altında ki textView’deki yazı farklı

Henüz Yorum Yapılmamış, İlk Yorumu Siz Yapın

Yorum Yollayın