在 Java 代码中,可以使用setTextSize()方法来设置 TextView 的文字大小,例如:

TextView textView = findViewById(R.id.text_view);
textView.setTextSize(18); // 设置文字大小为 18sp

在 XML 布局文件中,可以在 TextView 标签中使用android:textSize属性来设置文字大小,例如:

<TextView
    android:id="@+id/text_view"
    android:text='Hello World!'
    android:textSize="18sp"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />
Android TextView 文字大小设置方法 - Java 代码和 XML 布局

原文地址: https://www.cveoy.top/t/topic/okxr 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录