在 Android 中调整字体大小有以下几种方法:
1. 直接在布局文件中设置:
```xml
android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="16sp" /> ``` 2. 在代码中动态设置: ```java TextView textView = findViewById(R.id.my_text_view); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16); ``` 3. 在 styles.xml 中定义样式并应用: ```xml style="@style/MyTextStyle" android:layout_width="wrap_content" android:layout_height="wrap_content" /> ``` 4. 使用 resources 中的尺寸定义: ```xml android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="@dimen/text_size" /> ``` 5. 使用系统提供的文本大小预设: ```java TextView textView = findViewById(R.id.my_text_view); textView.setTextAppearance(R.style.TextAppearance_AppCompat_Large); ``` 这样可以使用系统定义的 Large 字体大小。其他预设有 Small、Medium、Large 等。 通过这些方法,你可以根据需求灵活地调整 Android 应用中字体的大小。