<TextView
android:id="@+id/textView"
android:text="TextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#B59999"
android:gravity="center"
android:textColor="#FFFFFF"
android:textSize="30sp"/>
public class MainActivity extends AppCompatActivity {
TextView textView, textView2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textView = findViewById(R.id.textView);
//TextView點擊事件
textView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//設定文字
textView.setText("顯示文字");
//字體顏色
textView.setTextColor(0xFF00FF00);
//字體大小
textView.setTextSize(30);
}
});
textView2 = findViewById(R.id.textView2);
//文字超連結
textView2.setText("https://www.google.com.tw");
textView2.setAutoLinkMask(Linkify.WEB_URLS);
textView2.setMovementMethod(LinkMovementMethod.getInstance());
}
}