Android 跑马灯效果是通过TextView来实现的,前提是TextView显示的内容必须比TextView控件分配的宽度宽,并且保证TextView里面的内容是单行显示,然后通过TextView的 ellipsize="marquee" 来设置跑马灯效果


代码:

  1. <?xmlversion="1.0"encoding="utf-8"?>
  2. <LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"
  3. android:orientation="vertical"
  4. android:layout_width="fill_parent"
  5. android:layout_height="fill_parent"
  6. >
  7. <!--singleLine="true":单行显示scrollHorizontally="true":水平滚动
  8. marqueeRepeatLimit="marquee_forever":重复次数,可设置整型值ellipsize="marquee":滚动-->
  9. <TextView
  10. android:layout_width="wrap_content"
  11. android:layout_height="wrap_content"
  12. android:singleLine="true"
  13. android:ellipsize="marquee"
  14. android:focusable="true"
  15. android:marqueeRepeatLimit="marquee_forever"
  16. android:focusableInTouchMode="true"
  17. android:scrollHorizontally="true"
  18. android:textSize="18dip"
  19. android:textColor="@android:color/white"
  20. android:text="需要滚动的文字,要注意文字的长度一定要比屏幕要宽才行!哈哈"
  21. />
  22. </LinearLayout>

更多相关文章

  1. 实现三星S3蒲公英水波纹效果(三)——Activity水波纹实现篇
  2. Android 图片预览模仿朋友圈查看图片效果放大图片,左右滑动 - tra
  3. Android自带的TabLayout实现滑动翻页效果(实例)
  4. Android 左右滑动切换页面或Activity的效果实现
  5. Android——为某个控件或者LinearLayout等添加水波纹效果
  6. 查看android里的数据库的内容的方法
  7. Android CountDownTimer实现定时器和倒计时效果

随机推荐

  1. Android控制水平方向字体缩放android:tex
  2. android:shape的使用
  3. Android(安卓)Property Animation属性动
  4. android的一些常用属性的说明
  5. Android中使用jiecaovideoplayer播放视频
  6. Android(安卓)Studio中隐藏状态栏和标题
  7. Android中http请求(C# MVC接收)
  8. Android模拟器简介—更新到最新的3.0 Hon
  9. android SharedPreferences(供选项使用)
  10. Android线程调度机制