android跑马灯
来源:互联网 发布:淘宝直通车定向推广 编辑:程序博客网 时间:2024/06/07 22:57
以前做过跑马灯的需求,今天又遇到了,再此mark下。
自定义TextView:
package com.adups.fota;import android.content.Context;import android.graphics.Rect;import android.text.TextUtils;import android.util.AttributeSet;import android.widget.TextView;/** * Created by wilson on 2017/5/31. */public class MyTextView extends TextView { public MyTextView(Context context) { super(context); createView(); } public MyTextView(Context context, AttributeSet attrs) { super(context, attrs); createView(); } public MyTextView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); createView(); } private void createView() { setEllipsize(TextUtils.TruncateAt.MARQUEE); setMarqueeRepeatLimit(-1); setFocusableInTouchMode(true); } @Override protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) { if (focused) { super.onFocusChanged(focused, direction, previouslyFocusedRect); } } @Override public void onWindowFocusChanged(boolean focused) { if (focused) { super.onWindowFocusChanged(focused); } } @Override public boolean isFocused() { return true; }}
布局引用:
<com.adups.fota.MyTextView android:singleLine="true"
通过复写isFocused()为true就可以实现多个TextView同时跑马灯的效果
阅读全文
0 0
- Android 跑马灯效果
- android跑马灯效果
- android跑马灯
- android跑马灯效果
- android 跑马灯
- android跑马灯文字效果
- Android 跑马灯
- android跑马灯实现
- Android跑马灯效果
- android 跑马灯实现
- Android 跑马灯效果
- android TextView跑马灯
- Android文字跑马灯
- android跑马灯效果
- Android 跑马灯
- Android TextView跑马灯
- android 跑马灯效果
- Android--最强跑马灯
- IBM Websphere MQ _02 MQ消息队列、通道、消息的创建及传输
- 归纳AOP在Android开发中的几种常见用法
- The Solution to Leetcode 119 Pascal's Triangle II
- 我的vim开发环境配置
- android三大动画的基本使用
- android跑马灯
- 正则表达式
- iOS自定义代码块
- 揭密出席第九届中国云计算大会的专家—近20个国家学者共话云计算大数据生态、应用
- iReport使用入门
- LeetCode 389. Find the Difference(异或)
- 自定义View 流程
- php微信
- 我也能爱莫能助了