4.2.1 TextView

 <TextView
        android:id="@+id/textview"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/hello_world" />android

private TextView textview;
 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  textview = (TextView)findViewById(R.id.textview);
  String string = "TextView示例,歡迎使用!";
  /*設置文本的顏色*/
  textview.setTextColor(Color.RED);
  /*設置字體大小*/
  textview.setTextSize(20); 
     /*設置文字背景*/
  textview.setBackgroundColor(Color.BLUE);
  /*設置TextView顯示的文字*/
  textview.setText(string);
 }ide

相關文章
相關標籤/搜索