• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

Android_TextView

武飞扬头像
树梢还未果
帮助1

学新通

跑马灯

  • android:singleLine="true"设置为单行显示
  • android:ellipsize="marquee"超出显示的部分设置为3个点
  • android:marqueeRepeatLimit="marquee_forever"字幕重复限制,无限循环
  • android:focusableInTouchMode="true"可在触摸模式下对焦
  • android:focusable="true"可聚焦的
<TextView
    android:padding="8dp"
    android:layout_width="150dp"
    android:layout_height="50dp"
    android:background="#000"
    android:gravity="center|left"
    android:text="跑马灯设置算法设计烦死了看风景"
    android:textColor="#fff"
    android:textSize="22sp"
    
    android:singleLine="true"
    android:ellipsize="marquee"
    android:marqueeRepeatLimit="marquee_forever"
    android:focusableInTouchMode="true"
    android:focusable="true"
  />

效果图

学新通

带阴影的TextView

  • android:shadowColor="#FF0000"设置阴影的颜色
  • android:shadowDx="10.0"设置X轴偏移量
  • android:shadowDy="10"设置Y轴偏移量
  • android:shadowRadius="3"设置阴影模糊度
<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="这是设置TextView有阴影"
    android:textSize="22sp"
    android:textColor="#000"
    
    android:shadowColor="#FF0000"
    android:shadowDx="10.0"
    android:shadowDy="10"
    android:shadowRadius="3"/>

效果图

学新通

带边框和背景颜色的TextView

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/border"
    android:text="Hello World!"
    />

背景文件的设置

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<!--  设置背景颜色,会被渐变的背景颜色覆盖  -->
    <solid android:color="@color/teal_700"/>
<!--    设置边框的大小以及颜色-->
    <stroke android:width="1dp" android:color="@color/black"/>
<!--    设置圆角的角度-->
    <corners android:radius="8dp" />
<!--    设置内边距-->
    <padding android:right="8dp"
            android:left="8dp"
        android:top="8dp"
        android:bottom="8dp"/>
    <!--
    渐变设置:
        android:startColor_开始颜色
        android:endColor_结束颜色
        android:angle_渐变角度
        android:type="sweep"_渐变类型   sweep:辐射状 ,linear:线性,radial-->
    <gradient android:startColor="#EC8B8B"
        android:endColor="#35E6D7"
        android:angle="60"
        android:type="sweep"/>
</shape>

效果图

学新通

TextView-超链接模式

  • android:autoLink="web"跳转到网页模式;phone:电话模式;email:电子邮件模式;map:地图模式;
<TextView
    android:id="@ id/text_web"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginStart="16dp"
    android:text="https://www.bilibili.com"
    android:textSize="24sp"
    android:autoLink="web"/>

效果图

学新通

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanhgiieab
系列文章
更多 icon
同类精品
更多 icon
继续加载