Android font size dp, sp, px system settings font size change performance

Android font size dp, sp, px system settings font size change performance

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical"
    tools:context=".MainActivity">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="zhangphil2023"
        android:textSize="15sp" />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="zhangphil2023"
        android:textSize="15dp" />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="zhangphil2023"
        android:textSize="15px" />

</LinearLayout>

Same as 15sp, 15dp, 15px

Display situation after the mobile phone system sets the default font size:

Set the mobile phone system to the maximum font display situation:

The font sp changes most obviously after the system setting font size changes. This is also true. The Android system design sp means that the size changes as the system adjusts the font size. However, dp and px have almost no changes to the naked eye.

Android rewrites getResources to avoid users adjusting system font size from affecting Android screen adaptation_Rewriting view's getresources_zhangphil's blog - CSDN blog Android screen adaptation has always been a headache. In addition, we must also consider the various user settings in the actual application scenarios of the APP. The most common user setting behavior is to set the font size of the mobile phone, such as setting the font to ultra-large or ultra-small, which brings about screen adaptation. Additional questions. One way to solve this problem is to avoid the impact of user size font settings by overriding getResources() in MainActivity (main activity, root activity). @Override pub_Override view's getresources https://blog.csdn.net/zhangphil/article/details/52911976 XML solution for Android horizontal and vertical screen switching View setting different sizes or equal scaling_android view scaling down_zhangphil Blog - CSDN Blog XML solution for Android horizontal and vertical screen switching View setting different sizes or equal scaling. In some applications, it involves switching between horizontal and vertical screens, and the View needs to be switched to different size ratios. In order to solve this development scenario, there are many solutions. For example, you can rewrite the View to achieve horizontal and vertical switching, and re-measure and redraw the size of the View in onMesure or the callback method of this type of View. You can also override and set the aspect ratio of the View based on the current horizontal and vertical screen switching in onConfigurationChanged_android view scaling down https://blog.csdn.net/zhangphil/article/details/73275311

Android adds AppCompatTextView adaptive font size and text width_appcompatbutton has different font sizes on android4.4 and android8.1_zhangphil's blog-CSDN blog Android adds AppCompatTextView adaptive font size and text width in Android's supportv7 package A new AppCompatTextView is added, which is an enhancement of the Android standard TextView: package android.support.v7.widget; public class AppCompatTextView extends TextView implement..._appcompatbutton The font size on android4.4 and android8.1 is different https:/ /blog.csdn.net/zhangphil/article/details/81388186 Android’s quick and convenient but not commonly used native tool class_zhangphil’s blog-CSDN Blog Android’s quick and convenient but not commonly used native tool class Android SDK native API , there are some commonly used tools, which can save trouble, effort and time when used properly, not to mention that they are officially provided by Android. Now I have collected some of them. DateUtils is a date and time tool class provided by Android itself, which contains many practical tool collections. For example, DateUtils.isToady() determines whether the incoming date and time is the current day. getRelativeTimeSpanString can be calculated https://blog.csdn.net/zhangphil/article/details/53198912

Guess you like

Origin blog.csdn.net/zhangphil/article/details/133150024