Android实现文字滚动播放效果

在开发时,我们会遇到文字过长,TextView不能完全展示,但又不想文字换行展示,这样有时会影响美观。这时我们就需要文字滚动播放,让用户可以看到所有的文字。

话不多说,直接上代码:

import android.content.Context;import android.util.AttributeSet;import android.widget.TextView;public class MarqueTextView extends TextView {    public MarqueTextView(Context context, AttributeSet attrs, int defStyle) {        super(context, attrs, defStyle);    }    public MarqueTextView(Context context, AttributeSet attrs) {        super(context, attrs);    }    public MarqueTextView(Context context) {        super(context);    }    @Override    public boolean isFocused() {        //true表示获取焦点        return true;    }}

使用方法:

<com.xxx.MarqueTextViewandroid:singleLine="true"   android:marqueeRepeatLimit="marquee_forever"   android:ellipsize="marquee"/>

更多相关文章

  1. Android开发系列(二十二):AdapterViewFlipper的功能和使用方法
  2. Android(安卓)播放视频常见问题小结
  3. Android(安卓)ListView 自定义背景滚动变黑问题
  4. Android前台服务 音乐播放器 前台服务
  5. 竖直方向,一次滚动一个页面的封装库。
  6. 使用SpannableString设置部分文字大小、颜色、超链接、点击事件
  7. Android中的SrollView滚动详解
  8. GraphWidget插件—简介
  9. android之文字处理

随机推荐

  1. android音乐播放器源码
  2. Android VNC Server on G1 (PC 远程控制
  3. Android开发之android命令大全
  4. Theme.NoTitleBar问题
  5. 自定义android RadioButton样式
  6. Android 检测更新库
  7. android noTouch 事件
  8. 使用SDK Manager更新时出现问题
  9. Android(安卓)仿今日头条频道管理(上)(GridV
  10. 杂谈:后台进程对Android性能的影响