android_基础_跑马灯实现

121 篇文章 1 订阅

转载自: https://blog.csdn.net/u013085291/article/details/46874019

其实没啥用的效果,只是习惯做做笔记了,仅此而已

注意跑马灯的长度必须大于控件的宽度

<TextView 
        android:layout_width="match_parent"  <!-- 宽度-->
        android:layout_height="wrap_content"  <!-- 高度-->
        android:ellipsize="marquee"  <!-- 设置跑马灯显示效果-->
        android:focusable="true"   <!-- 获取焦点 要显示跑马灯效果,必须要获取焦点-->
        android:singleLine="true"  <!-- 设置单行显示(很重要,关系到能不能正常显示) 有许多人说不能显示就是没有设置这个-->
        android:marqueeRepeatLimit="marquee_forever" <!-- 跑马灯次数,这里是一直循环显示-->
        android:focusableInTouchMode="true"    <!-- 在触摸模式下获得焦点-->
        android:scrollHorizontally="true"   <!-- 启用水平滚动条-->
        android:text="这才是真正的文字跑马灯效果,但是并没有什么卵用"  <!-- 文本内容-->
        android:textSize="30sp"    <!-- 字体大小-->
        >
    </TextView>
<!-- 实际实现 -->
	<TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ellipsize="marquee"
        android:scrollHorizontally="true"
        android:focusable="true"
        android:singleLine="true"
        android:focusableInTouchMode="true"
        android:marqueeRepeatLimit="marquee_forever"
        android:text="dwdwafawawgawgawgawgawhkuhukhukhukhkuhukhukhkuga"
        android:textSize="50sp"
        >
        <requestFocus/>
    </TextView>
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值