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 ...
随机推荐
- nginx实现反向代理,以反向代理tomcat为例
我的nginx和tomcat在同一台服务器上 我nginx安装的位置(因为我安装时使用的是./configure --prefix=/usr/etc/nginx)是/usr/etc/nginx,进入安 ...
- 使用btrace需要注意的几个问题
1. @ProbeClassName String clazz 此处String不能写为java.lang.String 2. location=@Location(Kind.RETURN) publ ...
- sofa graphql 2 rest api webhook 试用
sofa 的webhook实际上就是将graphql 的subscription 进行了扩展,当接受到sub 请求的时候 再做一次http 的转发处理,方便rest api 的访问 环境准备 环境还是 ...
- Primitives vs Objects
这里首先我们要了解什么是primitives 和 objects 其实理解起来很简单. 如果我们懂.NET开发就会知道C#中的值类型和引用类型. primitives variables contai ...
- mongodb之 mongodump 与 mongorestore
一.备份 和之前介绍的 mongoexport 的数据导出工具不同, mongodump 是将数据以二进制形式导出,而 mongoexport 导出的数据格式为 csv 或 json 格式: mong ...
- makedepend: command not found(转)
makedepend: command not found 解决方案: 修改Makefile MAKEDEPEND=$(CC) -M 参考: When I set CROSS_COMPILE, `MA ...
- JMeterPlugins插件监听器学习-监听器
JMeterPlugins插件监听器学习-监听器 1.jp@gc - Actiive Threads Over Time:不同时间活动用户数量展示(图表)2.jp@gc - AutoStop List ...
- 无界面运行Jmeter压测脚本 --后知者
原文作者---后知者 原文地址:http://www.cnblogs.com/houzhizhe/p/8119735.html [后知者的故事]:针对单一接口压测时出现了从未遇到的问题,设好并发量后用 ...
- [转]TA-Lib 安装
转自:https://mrjbq7.github.io/ta-lib/install.html Installation You can install from PyPI: $ pip instal ...
- Tomcat里面的APR配置问题研究
这里,之所以研究这个问题,是因为我们的生产系统Linux环境下的tomcat日志里面,启动信息的地方有这么一个WARNING. INFO: The APR based Apache Tomcat Na ...