Android TextView文字横向自动滚动(跑马灯)
TextView实现文字滚动需要以下几个要点:
public class ScrollingTextView extends TextView {
public ScrollingTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public ScrollingTextView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public ScrollingTextView(Context context) {
super(context);
}
@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;
}
}
在布局里调用自定义的TextView:
<com.example.rolltextdemo.ScrollingTextView
android:id="@+id/textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:singleLine="true"
android:text="@string/hello_world" />
Android TextView文字横向自动滚动(跑马灯)的更多相关文章
- Android:TextView 自动滚动(跑马灯) (转)
Android:TextView 自动滚动(跑马灯) TextView实现文字滚动需要以下几个要点: 1.文字长度长于可显示范围:android:singleLine="true ...
- Android TextView 字数过多,用跑马灯滚动形式实现
上代码: <TextView android:layout_width="120dp" android:layout_height="wrap_content&qu ...
- js无缝滚动跑马灯
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- Android:TextView文字跑马灯的效果实现
解决TextView文字显示不全的问题. 简单设置跑马灯的效果: <TextView android:id="@+id/textView" android:layout_wi ...
- Android 如何实现带滚动条的TextView,在更新文字时自动滚动到最后一行?
1.在布局文件中放置一个TextView,给它添加scrollbars和fadeScrollbars两个属性. 如下设置:滚动条为垂直滚动条,并且一直可见(当TextView中的文字行数超过页面能显示 ...
- TextView文字横向自己主动滚动
效果截图: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdTAxMjI4Nj ...
- Android中TextView不获取焦点可以实现跑马灯的效果
之前在网上找了很多关于TextView的跑马灯效果实现的例子,实现起来都存在一些问题,例如一种是完全重画一个跑马灯,还有就是只设置TextView的相关属性使其具有跑马灯的效果,总的来说这两种方法都是 ...
- Unity3D 文字滚动跑马灯效果
需求 在日常游戏中,文字滚动效果是比较常用的.例如日常游戏顶部的新闻公告,聊天系统的文字滚动,都属于这个范围. 思路 由于使用的地方比较广泛,所以希望能够尽量独立的游戏之外,能够做到随处使用的功能.N ...
- Textview在Listview中实现跑马灯效果
textview添加属性: android:singleLine="true" 表示单行显示 android:ellipsize="marquee" 设 ...
随机推荐
- 实例级别和类级别的static、构造函数、字段属性的简单介绍
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace 实例级别 ...
- 记录一下表格用poi的导出word
也是网上找的代码http://53873039oycg.iteye.com/blog/2152009,但是横向合并单元格没成功.只能用很蠢的办法建立了好多table public void fillT ...
- Android_用户界面概述和数据单位
一.UI界面概述 UI,对于一个应用而言用户界面是非常重要的一部分,是应用的脸,用户对应用第一个印象来自于界面,因此如果没有完美的用户界面,很难留住用户. 好的用户界面会极大提高用户的使用欲望并维护客 ...
- Druid 数据库用户密码加密 代码实现
druid-1.0.16.jar 阿里巴巴的开源数据连接池 jar包 明文密码+私钥(privateKey)加密=加密密码 加密密码+公钥(publicKey)解密=明文密码 程序代码如下: pack ...
- ios 开发 收起键盘的小技巧
在UIViewController中收起键盘,除了调用相应控件的resignFirstResponder方法外,还有另外三种方法: 1.重载UIViewController中的touchesBegin ...
- EF Core » 关系
对初学者理解关系很有用,先留下来,有时间边看边翻译. Caution 注意 This documentation is for EF Core. For EF6.x and earlier relea ...
- sealed(C# 参考)
sealed 修饰符可以应用于类.实例方法和属性.密封类不能被继承.密封方法会重写基类中的方法,但其本身不能在任何派生类中进一步重写.当应用于方法或属性时,sealed 修饰符必须始终与 overri ...
- pvresize - Unix, Linux Command
NAME pvresize - resize a disk or partition in use by LVM2 SYNOPSIS pvresize [-d|--debug] [-h|--help] ...
- 给文本标签UILabel添加长按复制功能
http://www.111cn.net/sj/iOS/104236.htm http://blog.csdn.net/lrenjun/article/details/12582927 自定义一个可复 ...
- MVC 特殊字符的显示
@(new HtmlString(HttpUtility.HtmlDecode(GPDetail.SimpleDescription)))