前言
1.能说出标签常用属性
2. 能做出安卓标签特殊效果
– 上下标
– 链接方式(网址、邮箱、电话)
– 渐变色边框
– 图片标签(上图下文……)
一、继承关系图
- TextView是View的子类,用于显示文本信息,而EditText都是TextView的子类,用于接收用户输入的数据。

二、标签常用属性
| 标签 | 属性 |
|---|---|
| text | 标签文本内容(@string/username) |
| textColor | 标签文本颜色(#ff00ff、@color/red) |
| textSize | 标签文本字号(单位用sp) |
| textStyle | 标签文本样式(normal |
| autoLink | 自动链接(none、web、email、phone、map) |
| background | 背景(背景色、背景图片、背景图形) |
| textAllCaps | 字母全大写 |
| drawableTop | 图片在上 |
| drawableBottom | 图片在下 |
| drawableLeft | 图片在左 |
三、案例演示
(一)最终的运行效果图

(二)实现步骤
1、创建安卓应用【TextViewDemo】


2、布局资源文件activity_main.xml

<?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:background="#000000"
android:orientation="vertical"
android:padding="10dp">
<TextView
android:id="@+id/tvNormal"
android:layout_width="wrap_content"

本文详细介绍了Android Studio中TextView的常见属性及其使用,包括标签的上下标、链接设置、渐变边框和图片标签等特殊效果的实现。通过一个TextViewDemo案例,逐步解析了从创建应用到实现各种效果的具体步骤,涉及布局资源、字符串资源、自定义边框配置文件和主界面类的编写,最终展示了运行效果并实现点击网址的跳转功能。
最低0.47元/天 解锁文章
589

被折叠的 条评论
为什么被折叠?



