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. Android(安卓)GraphicBuffer
  2. Android(安卓)Service startForeground不显示Notification的办法
  3. 转:Android(安卓)学习笔记3(控件)
  4. 【android】解决在图库中缩略图与实际图片不对应的问题
  5. Android(安卓)Wear 控件——WearableListView(附Demo)
  6. Android-基本控件(SeekBar 可拖动 滚动条的使用)
  7. Android(安卓)ActionBar中的按钮添加旋转动画
  8. 一个不错的启动菜单显示屏动画效果
  9. 【Android】ToolBar设置NavigationIcon不显示异常或自定义失败异

随机推荐

  1. 自学系列 | 俺今天就谈兴趣!
  2. 自学第五十五天
  3. C++中 unordered_map 与 map 的区别
  4. 谁的青春不迷茫?
  5. kubernetes 命令随手记录
  6. modelsim经常破解失败
  7. 动画:面试算法之求二叉树的下一节点
  8. 72.打印正方形脚本
  9. 学Linux云计算技术有意义吗?如何学习linux
  10. nginx1.19.1自动安装部署脚本