Android set global font size

Android changes the global font size <br> As the app becomes more and more user-friendly, this has caused the more and more abnormal needs. Here, I want to tell all my mobile development colleagues that he needs to be awkward, good, nonsense. Having said that, the following is the topic, how to change the font size globally, first AcTIvity inherits BaseacTIvity:
[java] view plain copy
Public class MainAcTIvity extends BaseAcTIvity {


@Override
Protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}

Then do this in BaseActivity,
[java] view plain copy
Public class BaseActivity extends Activity {

Private int states = 3;

@Override
Protected void onCreate(Bundle savedInstanceState) {


super.onCreate(savedInstanceState);


If (1 == states) {
setTheme(R.style.Default_TextSize_Small);


} else if (2 == states) {


setTheme(R.style.Default_TextSize_Middle);
} else {
setTheme(R.style.Default_TextSize_Big);
}
}
}

In general, we adjust the global font size in the app's settings menu. Here we simulate the big, medium and small fonts as 1, 2, and 3 respectively. Obviously we use the setTheme method to control the global font size. The key point is, how to set the theme, the font size will change, let's look at the xml layout file,
[java] view plain copy
Xmlns:tools="http://schemas.android.com/tools"
Android:layout_width="match_parent"
Android:layout_height="match_parent"
Android:orientation="vertical" >

Android:layout_width="wrap_content"
Android:layout_height="wrap_content"
Android:text="@string/hello_world"
Android:textSize="?textsize" />

Android:layout_width="wrap_content"
Android:layout_height="wrap_content"
Android:text="@string/hello_world"
Android:textSize="?textsize2" />

Android:layout_width="wrap_content"
Android:layout_height="wrap_content"
Android:text="@string/hello_world"
Android:textSize="?textsize3" />


Temperature Measurement Thermistor

Temperature Measurement Thermistor

Temperature measurement NTC Thermistor is small and light. With the characteristics of high stability and reliability, high accuracy, good consistency and fast response, this type of thermistor can be used in electronic thermometer, medical equipment and etc.

Temperature Measurement Thermistor,Medical Thermistor,Thermistor For Electronic Thermometer,Temperature Monitor

Feyvan Electronics Technology Co., Ltd. , https://www.fv-cable-assembly.com

Posted on