Android Studio 笔记5.1标签的使用

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

前言

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:layout_height="wrap_content"
        android:text="@string/normal"
        android:textColor="@android:color/holo_blue_bright"
        android:textSize="15sp"
        android:textStyle="normal" />

    <TextView
        android:id&#
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值