Android(安卓)跑马灯效果
16lz
2022-05-22
Android 跑马灯效果是通过TextView来实现的,前提是TextView显示的内容必须比TextView控件分配的宽度宽,并且保证TextView里面的内容是单行显示,然后通过TextView的 ellipsize="marquee" 来设置跑马灯效果
代码:
- <?xmlversion="1.0"encoding="utf-8"?>
- <LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- >
- <!--singleLine="true":单行显示scrollHorizontally="true":水平滚动
- marqueeRepeatLimit="marquee_forever":重复次数,可设置整型值ellipsize="marquee":滚动-->
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:singleLine="true"
- android:ellipsize="marquee"
- android:focusable="true"
- android:marqueeRepeatLimit="marquee_forever"
- android:focusableInTouchMode="true"
- android:scrollHorizontally="true"
- android:textSize="18dip"
- android:textColor="@android:color/white"
- android:text="需要滚动的文字,要注意文字的长度一定要比屏幕要宽才行!哈哈"
- />
- </LinearLayout>
更多相关文章
- Android(安卓)GraphicBuffer
- Android(安卓)Service startForeground不显示Notification的办法
- 转:Android(安卓)学习笔记3(控件)
- 【android】解决在图库中缩略图与实际图片不对应的问题
- Android(安卓)Wear 控件——WearableListView(附Demo)
- Android-基本控件(SeekBar 可拖动 滚动条的使用)
- Android(安卓)ActionBar中的按钮添加旋转动画
- 一个不错的启动菜单显示屏动画效果
- 【Android】ToolBar设置NavigationIcon不显示异常或自定义失败异