TextView实现跑马灯效果

来源:互联网 发布:lol装备模拟哪个软件 编辑:程序博客网 时间:2024/04/28 15:22

一、通过属性实现跑马灯效果

    <TextView        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:maxLines="1"        android:singleLine="true"        android:ellipsize="marquee"        android:focusable="true"        android:focusableInTouchMode="true"        android:text="这是一个跑马灯示例!这是一个跑马灯示例!这是一个跑马灯示例!这是一个跑马灯示例!这是一个跑马灯示例!这是一个跑马灯示例!" />

重要的代码

        android:singleLine="true" //设置为单行        android:ellipsize="marquee"//以横向滚动方式显示(需获得当前焦点时)        android:focusable="true"//获取焦点        android:focusableInTouchMode="true"//通过toucth来获得focus
0 0