Change native font size

Asked

Viewed 703 times

0

I’m developing an app and would like to know if it is possible to increase the standard Android font? From medium to large. What if it is, is it complex? I tried with Textappearence.Large as style but could not.

  • Have you solved your problem Darlan, or need some more information?

3 answers

0

You can set the font size beyond the property android:textAppearance, using this, android:textSize

Example:

<TextView
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:textSize="50sp"/>
  • I even did this, but I need to set the font size of the application. As if I would go to "Settings" of the device and change to Large. But via code.

  • So you don’t want to set the font size of your application, but rather your app to change the font size of the entire system? Would this be it?

  • Exactly. My app doesn’t need it because it’s already set. Think it’s hard to implement?

0

It would be better if you put your code here to see possible errors in your code.

But do the following test, in your main style put the item Textsize

<style name="AppTheme" parent="AppBaseTheme">
    <item name="android:textSize">@style/TextSize</item>
</style>

Create the Textsize style defined above

<style name="TextSize">
   <item name="android:textSize">20sp</item>
</style>

Now there in your Androidmanifest.xml on the tag application you check if you have the theme defined:

<application
    android:theme="@style/AppTheme" >
</application>
  • But my intention would be to change the source of android (native). But anyway, I will test and give a feedback. If you have no solution, you could use API to call this function?

0

You cannot change a size of standard source, but you can define a theme and where it is possible to change the font size. To learn more, you can read about Styles and themes in the developer Android reference documentation.

Example of theme definition:

<style name="MyTheme" parent="AppBaseTheme">
    <item name="android:textSize">18sp</item>
</style>

This way above, you will set a standard size for all TextView within your application. To set a specific size individually, you can do so:

<TextView
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:text="Trump eh o novo presidente dos EUA"
   android:textSize="40sp"/>

Always try to use SP, because it is dimensioned independently in relation to the normal font size of the device.

Details

  • I even did this, but I need to set the font size of the application. As if I would go to "Settings" of the device and change to Large. But via code.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.