0

My application is taking font(Size) and other setting of device rather than the setting of font of application which changes the look and feel of the application. I want application will be remain on its setting or take application setting rather than device setting of font size etc, is there any way to do that ?

Different controls have different size and face of fonts, right now it takes font size of device not local application's font size

In short how to False device setting in Application?

Soniya
  • 600
  • 7
  • 34
  • This is not possible. You can however set the font for individual views with the setTypeface() method. – tpbapp Jun 12 '14 at 07:38

2 Answers2

0

In layout use dp for font size instead of sp. In this case font size will not be affected by settings.

To set custom font you need to do something like this

TextView tv = (TextView) findViewById(R.id.label_text);
Typeface face = Typeface.createFromAsset(getAssets(),
            "fonts/myfont.ttf");
tv.setTypeface(face);

This also will not be affected by the system font. Also You can make custom TextView to address all this stuff.

Minas
  • 1,422
  • 16
  • 29
0

Try this:

<style name="AppTheme" parent="AppBaseTheme">
    <item name="android:textViewStyle">@style/RobotoTextViewStyle</item>
    <item name="android:buttonStyle">@style/RobotoButtonStyle</item>
</style>

<style name="RobotoTextViewStyle" parent="android:Widget.TextView">
    <item name="android:fontFamily">sans-serif-light</item>
</style>

<style name="RobotoButtonStyle" parent="android:Widget.Holo.Button">
    <item name="android:fontFamily">sans-serif-light</item>
</style>

Apply Style to your whole application in manifest:

<application
    android:theme="@style/AppTheme" >
</application>

And you're done:

Original URL: How to set default font family for entire Android app

Community
  • 1
  • 1
Ayub
  • 510
  • 2
  • 6
  • 21