5.3 标签控件

一、标签常用属性

属性 作用
text: 标签文本内容(@string/username)
textColor: 标签文本颜色(#ff00ff、@color/red)
textSize: 标签文本字号(单位用sp)
textStyle: 标签文本样式(normal
autoLink: 自动链接(none、web、email、phone、map)
background: 背景(背景色、背景图片、背景图形)
textAllCaps: 字母全大写
drawableTop: 图片在上
drawableBottom: 图片在下
drawableLeft: 图片在左
drawableRight : 图片在右

二、案例演示

1、创建安卓应用

  • 基于Empty Activity模板创建安卓应用 - TextViewDemo
    在这里插入图片描述

2、字符串资源文件

在这里插入图片描述

<resources>
    <string name="app_name">标签演示</string>
    <string name="normal">常规:Welcome to Android World</string>
    <string name="bold">粗体:Welcome to Android World</string>
    <string name="italic">斜体:Welcome to Android World</string>
    <string name="bold_italic">粗斜:Welcome to Android World</string>
    <string name="all_caps">全大写:Welcome to Android World</string>
    <string name="theorem">勾股定理:</string>
    <string name="equation">化学方程式:</string>
    <string name="android">安卓</string>

</resources>

3、自定义边框配置文件

在这里插入图片描述
在这里插入图片描述


<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">

    <corners android:radius="5dp" />
    <solid android:color="#dddddd" />
    <stroke
        android:width="1dp"
        android:color="#555555" />

    <padding
        android:bottom="10dp"
        android:left="10dp"
        android:right="10dp"
        android:top="10dp" />

    <gradient
        android:centerColor="#ffff00"
        android:endColor="#00ff00"
        android:startColor="#aaaaaa" />

</shape>

4、主布局资源文件

<?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/tv_normal"
        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="@+id/tv_bold"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/bold"
        android:textColor="@android:color/holo_green_light"
        android:textSize="15sp"
        android:textStyle="bold" />

    <TextView
        android:id="@+id/tv_italic"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/italic"
        android:textColor=
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值