- <TextView
- android:id="@+id/tv_ont"
- android:layout_width="match_parent"
- android:layout_height="100dp"
- android:gravity="center"
- android:shadowColor="@color/red"
- android:shadowDx="10"
- android:shadowDy="10"
- android:shadowRadius="3.0"
- android:text="@string/tv_one"
- android:textColor="@color/black"
- android:textSize="30dp" />
上面的TextView中有下述几个属性:
center_vertical 文本位置为垂直居中
center_horizontal 文本位置为水平居中
center 文本位置为水平/垂直居中
文字阴影 android:shadowColor:设置阴影颜色,需要与shadowRadius一起使用哦! android:shadowRadius:设置阴影的模糊程度,设为0.1就变成字体颜色了,建议使用3.0 android:shadowDx:设置阴影在水平方向的偏移,就是水平方向阴影开始的横坐标位置 android:shadowDy:设置阴影在竖直方向的偏移,就是竖直方向阴影开始的纵坐标位置