TextView跑马灯效果和TextView垂直…

本文介绍了如何在Android中实现TextView的跑马灯效果和垂直滚动。通过设置特定属性,如`ellipsize`和`marqueeRepeatLimit`,可以实现水平跑马灯。同时,文中提供了一个自定义的TextView垂直滚动的示例,适用于欢迎词较多的情况。
摘要由CSDN通过智能技术生成

TextView跑马灯效果:

  转载 农民伯伯: http://www.cnblogs.com/over140/    

正文

   本文得益于文章1的提示,虽然没全看明白,但是看见代码就复制下来然后测试,果然给我撞出来了- - #。

  一、效果图

    

 

 <TextView android:layout_width="100px"
        android:layout_height="wrap_content"
        android:textColor="@android:color/white"
        android:ellipsize="marquee"
        android:focusable="true"
        android:marqueeRepeatLimit="marquee_forever"
        android:focusableInTouchMode="true"
        android:scrollHorizontally="true"
        android:text="这才是真正的文字跑马灯效果"
        >
    </TextView>

 

TextView垂直滚动:

    项目中欢迎词多的时候需要实现上下滚动,了解到在android中TextView可以轻松实现横向跑马灯效果,但是对垂直滚动没有直接的支持方法,于是百度上谷歌,谷歌上百度,最终还是没有发现一个拿来即用的demo,呵呵,于是自己研究了下,写了一个可以实现TextView垂直滚动的 demo,由于项目需要,在这里我使用的是AbsoluteLayout布局,左右键切换时更改滚动内容,希望此demo能给有同样需求的童鞋们带来帮助!

  <?xml version="1.0" encoding="utf-8"?> 
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 
 
    <TextView 
        android:id="@+id/tScroll" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:maxLines="5" 
        android:scrollbars="none" 
        android:singleLine="false" 
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值