基础属性
- android:layout_width 组件的宽度
- android:layout_height 组件的高度
- android:id 为TextView设置-个组件id
- android:text: 设置显示的文本内容
- android:textColor 设置字体颜色
- android:textyle 设置字体风格。三个可选值。norml无效果), bold(加粗), ialc(斜体)
- android:textSize 字体大小,单位一般是用sp
- android:background 控件的背景颜色,可以理解为填充整个控件的颜色,可以是图片
- android:gravity 控件中内容的对齐方向
阴影风格
- android:shadowColor:设置阴影颜色,需要和shadowRadius一起使用
- android:shadowRadius:设置阴影的模糊程度,0.1相当于字体颜色,建议3.0
- android:shadowDx:设置阴影水平方向的偏移量,即水平方向阴影开始的横坐标
- android:shadowDy:设置阴影垂直方向的偏移量,即垂直方向阴影开始的纵坐标
滚动效果
- androld:singleLine 内容单行显示
- android:focusable 是否可以获取焦点
- android:focusableInTouchMode 用于控制视图在触摸模式下是否可以聚焦
- android:lellpsize 省略号(。。。)位置
- android:marqueeRepeatLimit 字幕动画重复的次数
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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">
<TextView
android:id="@+id/tv_one"
android:text="@string/tv_one"
android:textColor="@color/black"
android:textStyle="italic"
android:textSize="30sp"
android:background="@color/lightgray"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="200dp"
android:shadowColor="@color/red"
android:shadowRadius="3.0"
android:shadowDx="10"
android:shadowDy="10"
android:singleLine="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
/>
</LinearLayout>