安卓跑马灯效果

跑马灯效果
当一行文本的内容太多,导致无法全部显示,也不想分行展示时,只能让文字从左向右滚动显示,类 似于跑马灯。电视在播报突发新闻时经常在屏幕下方轮播消息文字,比如" 快讯:我国选手 *** 在刚刚结束 的** 比赛中为中国代表团夺得第 ** 枚金牌 "。

XML 复制代码
 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#00aaff"
    android:orientation="vertical"
    >

<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="10dp"
    android:gravity="center"
    android:textSize="35sp"
    android:text="跑马灯效果"/>


<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
android:layout_marginTop="20dp"
    android:singleLine="true"
    android:ellipsize="marquee"
    android:focusable="true"
    android:focusableInTouchMode="true"
    android:textColor="#ffaa00"
    android:textSize="40sp"
    android:text="红色境界前台风将至,关闭门窗,在家休息"/>

</LinearLayout>

跑马灯滚动的效果界面如图 。左图为跑马灯文字在滚动中,右图为跑马灯文字停止滚
动。

相关推荐
传奇开心果5 小时前
【Flutter踩坑排雷】第3课:const 误用坑|const 错误使用引发 UI 异常与性能损耗
android·flutter
哲鲤5 小时前
AOSP思绎|Android 多媒体:一段视频为什么需要这么多服务
android
阿杰m5 小时前
Android源码第三章:Handler、Looper 与 MessageQueue——一条消息如何入队、唤醒并执行
android
海雅达手持终端PDA8 小时前
巡线、深井、爆管抢修与极寒水网的硬件矩阵怎么配?海雅达水务巡检终端PDA选型指南
android·物联网·5g·集成测试·能源·政务
恋猫de小郭10 小时前
Flutter 开始支持 Jetpack Compose Platform View
android·前端·flutter
三少爷的鞋1 天前
Android 架构七条铁律:架构师真正设计的不是代码,而是秩序
android
xiangxiongfly9151 天前
Android GsonFactory总结
android·gson·gsonfactory
WythePlus1 天前
Android 14 SELinux策略深度解析
android·安全策略·selinux策略
俩个逗号。。1 天前
Kotlin flow 详解
android·开发语言·kotlin
橙光成长1 天前
android-ad-cleaner:android免 Root 批量关闭系统开屏与营销推送
android·1024程序员节