Android app widget中实现跑马灯效果(非widget部件也实用)
原文地址:http://blog.csdn.net/luoyebuguigen/article/details/37533631
关键是需要在TextView中嵌入requestForcus标签才会有效果。
<TextView
android:id="@+id/widget_item_name"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:paddingLeft="10dip"
android:paddingRight="10dip"
android:text="Baby Room"
android:textColor="@android:color/white"
android:textSize="@dimen/testSize18"
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:focusable="true"
android:focusableInTouchMode="true">
<requestFocus
android:focusable="true"
android:focusableInTouchMode="true"
android:duplicateParentState="true"/>
</TextView>
另外还有不使用ScrollView也可滚动的方法
TextView textview = (TextView) findViewById(R.id.text);
/** *
* 只有调用了该方法,TextView才能不依赖于ScrollView而实现滚动的效果。
* 要在XML中设置TextView的textcolor,否则,当TextView被触摸时,会灰掉。
*/
textview.setMovementMethod(ScrollingMovementMethod.getInstance());
xml如下:
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="18sp"
android:scrollbars="vertical"
android:maxLines="12"
android:textColor="@color/white"
android:id="@+id/text"
android:text="hello world"
></TextView>
备注:有些字符串为英文时,无法滚动,需要在字符串增加一个换行符
// 单曲 有些歌曲名和艺术家名是英文,无法进行滚动,需要再后面加一个回车符
ct_dec_playbar.setText(getString(R.string.play_title, title, artistname) + "\n");
Android app widget中实现跑马灯效果(非widget部件也实用)的更多相关文章
- android中实现跑马灯效果以及AutoCompleteTestView与MultiAutoCompleteTextView的学习
跑马灯效果 1.用过属性的方式实现跑马灯效果 属性: android:singleLine="true" 这个属性是设置TextView文本中文字 ...
- Android 实现多行文本跑马灯效果
Android TextView 实现跑马灯的效果很简单,只要加三个属性就可以了. android:ellipsize="marquee" android:focusable=&q ...
- Android TextView 横向滚动(跑马灯效果)
Android TextView 中当文字比較多时希望它横向滚动显示,以下是一种亲測可行的方法. 效果图: 1.自己定义TextView,重写isFocused()方法返回true,让自己定义Text ...
- Textview在Listview中实现跑马灯效果
textview添加属性: android:singleLine="true" 表示单行显示 android:ellipsize="marquee" 设 ...
- Android开发之TextView实现跑马灯效果
TextView及其子类,当字符内容太长显示不下时可以省略号代替未显示的字符:省略号可以在显示区域的起始,中间,结束位置,或者以跑马灯的方式显示文字(textview的状态为被选中). 其实现只需在x ...
- Android textView点击滚动(跑马灯)效果
布局文件: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:to ...
- 自定义有焦点的TextView实现广告信息左右一直滚动的跑马灯效果
import android.content.Context; import android.text.TextUtils; import android.util.AttributeSet; imp ...
- TextView标签的属性和跑马灯效果
text:显示的内容 textSize:文本的大小 textColor:文本的颜色 visibility:可见性 默认可见,invisible:表示不可见,但对控件的显示区域做了保留 gone:隐藏 ...
- Android 开发笔记___textvieww__跑马灯效果
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=&quo ...
随机推荐
- linux服务器进程信息查看命令
#lsof 列出当前系统打开文件,常与-i选项使用,用于查看某个端口被哪个程序占用 [root@bogon ~]# lsof -i:80 COMMAND PID USER FD TYPE DEVICE ...
- mysqldump命令之常用模板
##=====================================================## ## 在Master上导出所有数据库 /export/servers/mysql/b ...
- jsonDB使用手冊
已在github上建立项目:https://github.com/ThinkerCodeChina/jsonDB 博客:http://blog.csdn.net/thinkercode/ 简单介绍: ...
- C# to IL 1 Introduction to Microsoft’s IL(MSIL 介绍)
The code that we write in a programming language like C#, ASP+ or in any other .NETcompatible langua ...
- MySQL 出现 Host is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'
MySQL 出现 Host is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts' 一大 ...
- JAVA中通过Hibernate-Validation进行参数验证
在开发JAVA服务器端代码时,我们会遇到对外部传来的参数合法性进行验证,而hibernate-validator提供了一些常用的参数校验注解,我们可以拿来使用.1.maven中引入hibernate- ...
- Linux 操作系统下,安装软件 apt-get、yum 的区别
Linux 操作系统主要分为两大类: RedHat系列:Redhat.Centos.Fedora等: Debian系列:Debian.Ubuntu等. yum(Yellow dog Updater, ...
- redis 的 docker 镜像使用
redis 镜像使用: 创建容器(暴露端口:6379,使用 Redis 可视化界面工具(如:Fastoredis)连接 redis 时连接该端口): docker run -it -p 6379:63 ...
- webpack 4 升级点
webpack 4 升级点: 默认entry为./src,默认output为/dist sideEffects 在webapck2开始支持ESModule后,webpack提出了tree-shakin ...
- win10系统 安装好composer后 cmd 命令行下输入composer提示不是内部或外部的命令,也不是可执行的程序或批处理文件
在 windows CMD 下运行composer 出现错误提示: 不是内部或外部命令,也不是可运行的程序或批处理文件,这是因为没有配置 PATH 环境变量. 以 win10 为例,找到此电脑右击选择 ...