安卓跑马灯效果

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

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>

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

相关推荐
非专业程序员Ping1 小时前
HarfBuzz概览
android·ios·swift·font
Jeled2 小时前
「高级 Android 架构师成长路线」的第 1 阶段 —— 强化体系与架构思维(Clean Architecture 实战)
android·kotlin·android studio·1024程序员节
明道源码4 小时前
Kotlin 控制流、函数、Lambda、高阶函数
android·开发语言·kotlin
消失的旧时光-19436 小时前
Kotlin × Gson:为什么遍历 JsonObject 要用 entrySet()
android·kotlin·数据处理·1024程序员节
G果8 小时前
安卓APP页面之间传参(Android studio 开发)
android·java·android studio
曾凡宇先生9 小时前
无法远程连接 MySQL
android·开发语言·数据库·sql·tcp/ip·mysql·adb
zhangphil11 小时前
Android GPU的RenderThread Texture upload上传Bitmap优化prepareToDraw
android
柿蒂12 小时前
聊聊SliverPersistentHeader优先消费滑动的设计
android·flutter
假装多好12313 小时前
android三方调试几个常用命令
android·1024程序员节·三方,gms
侧耳42913 小时前
android11禁止安装apk
android·java·1024程序员节