2021/1/25

TextView(文本框),用于显示文本的一个控件

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity"
    android:gravity="center"
    android:background="#8fffad">

    <TextView
        android:id="@+id/txtOne"
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:gravity="center"
        android:text="TextView(显示框)"
        android:textColor="#EA5246"
        android:textStyle="bold|italic"
        android:background="#000000"
        android:textSize="18sp" />

</RelativeLayout>
  • id:为TextView设置一个组件id,
  • layout_width:组件的宽度
  • layout_height:组件的高度
  • gravity:设置控件中内容的对齐方向,TextView中是文字,ImageView中是图片
  • text:设置显示的文本内容
  • textColor:设置字体颜色,
  • textStyle:设置字体风格,
  • textSize:字体大小
  • background:控件的背景颜色,控件的颜色,可以是图片
原文地址:https://www.cnblogs.com/qiangini/p/14864693.html