zoukankan      html  css  js  c++  java
  • android用TextView实现跑马灯效果

    今天搞啦很久,其实很简单,就加几个属性就可以啦!

    图如下 :

    有的说要重写TextView方法,有的说要设置固定长度,但是我没重写也没有设置固定长度也弄出来啦!跑在2.3.3的手机上面。就是不知道其他地方能不能实现这种效果!

    代码如下:(其他地方代码没什么关系) 

    1.   <TextView  
    2. android:layout_width="fill_parent"  
    3. android:layout_height="wrap_content"    
    4. android:id="@+id/notice"    
    5. android:background="@color/black20"     
    6. android:text="他们说这里是要放广告的,就是看看能不能动啊!长点...!!!!..."    
    7. android:ellipsize="marquee"    
    8. android:gravity="center"    
    9. android:textStyle="bold"    
    10. <span style="color:#ff0000;">android:focusable="true"    
    11. android:marqueeRepeatLimit="marquee_forever"    
    12. android:focusableInTouchMode="true"    
    13. android:scrollHorizontally="true"    
    14. android:singleLine="true"  </span>  
    15. android:textSize="@dimen/activity_Textsize15_4.0"    
    16. />    
    17.    

    注意的就是内容一点要够长才会滚动,不然就不会滚动。 红色标记的代码是关键代码。

  • 相关阅读:
    location.href
    网络载入数据和解析JSON格式数据案例之空气质量监測应用
    概率dp HDU 3853
    poj2031-Building a Space Station(最小生成树,kruskal,prime)
    在JS数组指定位置插入元素
    leetcode
    leetcode笔记:Range Sum Query
    最优解算法的讨论
    NYOJ_77 开灯问题
    C++调用Lua的性能測试
  • 原文地址:https://www.cnblogs.com/android100/p/android-textview-light.html
Copyright © 2011-2022 走看看