Android前端学习——TextView
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <TextView android:id="@+id/tv1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/tv_1" android:textColor="#000000" android:textStyle="bold" android:textSize="30sp" android:gravity="center" android:shadowColor="@color/rad" android:background="@color/yellow" android:shadowRadius="5.0" android:shadowDx="10" android:shadowDy="10" /> </LinearLayout>
Textview属性:
layout_width和layout_height:match_parent:填充整个容器
wrap_content:随着控件内容的增大而增大
直接输入数字xxdp:明确规定宽高
id:指定控件的名字,为java代码获取控件
text:设置显示的文本内容
textColor:设置字体的颜色
textStyle:字体风格:bold:字体加粗
normal:无效果
italic:斜体
textSize:设置字体大小用sp
background:设置背景颜色
gravity:设置文字在控件中的位置
设置textview阴影效果:shadowColor:设置阴影颜色
shadowRadius:设置阴影模糊都
shadowDx:设置阴影平行距离
shadowDy:设置阴影向下距离
自定义颜色,文字:在values文件夹下有colors.xml、string.xml、themes.xml他们分别为颜色、字体、主题
本文来自博客园,作者:猫与少年,转载请注明原文链接:https://www.cnblogs.com/MrZhaoprogramnotes/p/15255264.html

浙公网安备 33010602011771号