Android 中改变 TextView 大小的主要方法有以下几种:
1. 在布局文件中设置 `android:textSize` 属性:
```xml
android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello, World!" android:textSize="24sp" /> ``` 2. 在 Java 代码中使用 `setTextSize()` 方法: ```java TextView textView = findViewById(R.id.my_text_view); textView.setTextSize(24f); ``` 3. 使用 `sp` 单位,这种单位会根据用户的字体大小设置进行自适应: ```xml android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello, World!" android:textSize="18sp" /> ``` 4. 使用 `dimen` 资源文件定义字体大小,然后在布局文件或代码中引用: ```xml android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello, World!" android:textSize="@dimen/text_size_large" /> ``` 这些是 Android 上最常用的改变 TextView 字体大小的方法。选择哪种方式取决于你的具体需求和项目结构。通常来说,在布局文件中使用 `android:textSize` 属性是最简单直接的方法。