Android 跑马灯效果
16lz
2021-01-23
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>
更多相关文章
- 实现三星S3蒲公英水波纹效果(三)——Activity水波纹实现篇
- Android 图片预览模仿朋友圈查看图片效果放大图片,左右滑动 - tra
- Android自带的TabLayout实现滑动翻页效果(实例)
- Android 左右滑动切换页面或Activity的效果实现
- Android——为某个控件或者LinearLayout等添加水波纹效果
- 查看android里的数据库的内容的方法
- Android CountDownTimer实现定时器和倒计时效果