android 实现TextView实现跑马灯形式的字体
来源:互联网 发布:天地图框架数据标准 编辑:程序博客网 时间:2024/05/09 13:05
在android中,如何让TextView实现跑马灯效果呢?今天我们就来讲讲如何实现吧。
<TextView
android:id="@+id/t1"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:scrollX="2dp"
android:singleLine="true"
android:text="此处为文本显示区域的宽度此值必须比你的文本宽度要小否则是没有效果的"
android:textColor="#ff00ff00" >
</TextView>
如何只是这样,不会出现跑马灯效果,我们还要处理一下。
TextView t= (TextView) findViewById(R.id.t1);
t.setTextSize(30);
t.setHorizontallyScrolling(true);
t.setFocusable(true);
t.setFocusableInTouchMode(true);
因为我们的TextView就能聚焦,才能滚动效果。效果如图一,图二所示:
(图一) (图二)
如果我们不在代码中进行聚焦,我们也可以在布局文件中设置:
<TextView
android:id="@+id/t1"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:scrollX="2dp"
android:singleLine="true"
android:text="此处为文本显示区域的宽度此值必须比你的文本宽度要小否则是没有效果的"
android:textColor="#ff00ff00"
android:clickable="true"
android:focusable="true"
android:focusableInTouchMode="true">
-_- @a little a day
- android 实现TextView实现跑马灯形式的字体
- Android TextView 跑马灯效果的实现
- Android实现跑马灯效果的TextView
- android学习:TextView 跑马灯的实现
- android Textview跑马灯的实现
- android--TextView实现跑马灯
- Android TextView实现跑马灯
- TextView跑马灯的实现
- TextView跑马灯的实现
- TextView实现跑马灯
- TextView实现跑马灯
- TextView实现跑马灯
- TextView实现跑马灯
- TextView实现跑马灯
- android TextView的跑马灯效果的实现
- Android TextView跑马灯效果实现
- android textview跑马灯效果实现
- android中TextView实现单行跑马灯
- LeetCode-Best Time to Buy and Sell Stock III
- 2015年寒假总结
- 【转载】在jsp中调用报表IReport+JasperReport
- git clean
- SuspendThread、ResumeThread
- android 实现TextView实现跑马灯形式的字体
- 10招让你成为杰出的Java程序员
- Stm32F030用Coocox工程进行Bootloader升级时程序跑飞
- 每日时间表
- 学习文档
- dyld: Library not loaded:
- 内存对齐规则
- 搭建SublimeText3的Markdown开发平台
- 每个程序员都可能犯过的10个错误