1

Is there a way to change the font of the whole android application ?

I'm aware of changing TextView's font. I want to change the font for all my listview items, TextViews, ButtonTexts, ...etc in all the activities.

Can I do something about that? Is it a Manifest-related thing?

Thanks.

Community
  • 1
  • 1
iTurki
  • 16,292
  • 20
  • 87
  • 132

2 Answers2

0

Unfortunately, there's not a way to set a default font for the entire app. You will have to perform setTypeface(tf) on each View.

An alternative approach is to subclass each View type, and apply the typeface in its constructor, as suggested in this answer.

Community
  • 1
  • 1
Paul Lammertsma
  • 37,593
  • 16
  • 136
  • 187
0

hi check this http://developer.android.com/guide/topics/ui/themes.html

in this define the style and theme for the application.

Creating custom style and theme and set for single/multiple control with different style and theme

this is my main.xml file

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:id="@+id/linear">
<TextView android:layout_width="fill_parent"
    android:layout_height="wrap_content" android:text="@string/hello" style="@style/CodeFont"/>
<Button android:id="@+id/btn" android:layout_width="200dp"
    android:layout_height="wrap_content" android:text="Click" style="@style/CodeFont"/>
<ImageView android:id="@+id/img_preview"
    android:layout_width="fill_parent" android:layout_height="wrap_content" />
</LinearLayout>

and this is my style.xml file

<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="CodeFont" parent="@android:style/TextAppearance.Medium">
    <item name="android:layout_width">fill_parent</item>
    <item name="android:layout_height">wrap_content</item>
    <item name="android:textColor">#00FF00</item>
    <item name="android:typeface">monospace</item>
</style>
</resources>
Pratik
  • 30,639
  • 18
  • 84
  • 159
  • I didn't get what are you trying to say ! – iTurki Jul 18 '11 at 10:54
  • sorry for my poor english. we create ui using xml file so in that we can create custom style and theme for the control(s). so create the xml file as custom style like in that like and set into the specific control – Pratik Jul 18 '11 at 10:59
  • My question is about the FONT not the styles ! – iTurki Jul 18 '11 at 11:04
  • @iturki check latest answer for font create one application just copy and paste above code into your application and run it – Pratik Jul 18 '11 at 11:16
  • 1
    Can I change the `monospace` to Not built-in font? I doubt it – iTurki Jul 18 '11 at 12:00