9.22

<TextView

    android:layout_width="wrap_content"

    android:layout_height="wrap_content"

    android:text="Hello, Android!"

    android:textSize="18sp"

    android:textColor="#FF0000" />

// 获取 TextView 对象

TextView textView = findViewById(R.id.textView);

 

// 设置文本内容

textView.setText("Dynamic Text");

 

// 设置字体大小(单位为 sp)

textView.setTextSize(20); // 设置字体大小为 20sp

 

// 设置字体颜色

textView.setTextColor(Color.BLUE); // 设置字体颜色为蓝色

 

posted @ 2024-09-22 21:40  赵千万  阅读(5)  评论(0)    收藏  举报