TextView实现多个TextView对象的走马灯效果
1:自定义一个控件继承TextView,重写isFocused方法,返回值为true;
- package com.example.helloandroid;
- import android.R.bool;
- import android.content.Context;
- import android.util.AttributeSet;
- import android.view.ViewDebug.ExportedProperty;
- import android.widget.TextView;
- public class MarqueeText extends TextView {
- public MarqueeText(Context context) {
- super(context);
- // TODO Auto-generated constructor stub
- }
- public MarqueeText(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- // TODO Auto-generated constructor stub
- }
- public MarqueeText(Context context, AttributeSet attrs) {
- super(context, attrs);
- // TODO Auto-generated constructor stub
- }
- @Override
- @ExportedProperty(category = "focus")
- public boolean isFocused() {
- // TODO Auto-generated method stub
- return true;
- }
- }
2:给两个text空间添加属性,记得一定加上包名以及类名
- <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:paddingBottom="@dimen/activity_vertical_margin"
- android:paddingLeft="@dimen/activity_horizontal_margin"
- android:paddingRight="@dimen/activity_horizontal_margin"
- android:paddingTop="@dimen/activity_vertical_margin"
- tools:context=".MainActivity" >
- <com.example.helloandroid.MarqueeText
- android:id="@+id/textView1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:singleLine="true"
- android:ellipsize="marquee"
- android:focusable="true"
- android:focusableInTouchMode="true"
- android:text="@string/hello_world" />
- <com.example.helloandroid.MarqueeText
- android:layout_below="@id/textView1"
- android:layout_margin="10dp"
- android:id="@+id/textView2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:singleLine="true"
- android:ellipsize="marquee"
- android:focusable="true"
- android:focusableInTouchMode="true"
- android:text="@string/hello_world" />
- </RelativeLayout>
TextView实现多个TextView对象的走马灯效果的更多相关文章
- android - TextView单行显示...或者文字左右滚动(走马灯效果)
条件 TextView单行显示,文字左右滚动(走马灯效果)实现条件: 实现单行设置固定宽度或者设置权重都行 代码 TextView滚动必须写下面几个属性 android:singleLine=&quo ...
- Android TextView走马灯效果
布局: <TextView android:id="@+id/myTextView" android:layout_width="match_parent" ...
- android中设置TextView/Button 走马灯效果
在Android的ApiDemo中,有Button的走马灯效果,但是换作是TextView,还是有一点差异. 定义走马灯(Marquee),主要在Project/res/layout/main.xml ...
- Jquery 图片走马灯效果原理
本篇只讲解水平走马灯效果,垂直向上走马灯效果不讲解,原理一样,但是水平走马灯效果有一个小坑.待会讲解 照例先上代码: HTML: <div class="box"> & ...
- 分页技巧__在项目中使用QueryHelper辅助对象实现分页效果
分页技巧__在项目中使用QueryHelper辅助对象实现分页效果 QueryHelper 用于辅助拼接HQL语句 addCondition("t.type=?", "精 ...
- css3 走马灯效果
纯css3实现了一个正六边形的走马灯效果,记录一下css3动画的学习情况,效果如下: 主要用到的css3技术有:keyframes.perspective.perspective-origin.tra ...
- vue 实现走马灯效果
Part.1 问题 在写一个H5页面时遇到一个需求,头部公告需要滚动变换,需要实现一个走马灯效果 Part.2 实现 我的做法:利用 定时器 + CSS3 变换公告数组的顺序 从而实现走马灯效果 ...
- 初学VUE 走马灯效果
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 让TextView里面的文字逐个显示的动画效果实现(1)
最近使用TextView时想要实现里面的文字逐个显示的动画效果,就如同打字一样. 主要实现思想:新建一个TextView的派生类,先将要逐个显示的字符串保存变量 mOriginalStr 中,然后启动 ...
随机推荐
- MySQL 复制
第一步:为配置主数据库与备数据库 主:server_id = 1 log_bin = E:\mysql_log_bin #复制事实上是二进制文件在备库上的重做,所以要支持二进制文件. 备: ...
- Y5V贴片电容(MLCC)容量范围速查表
Y5V贴片电容简述 Y5V贴片电容属于EIA规定的Class 2类材料的电容.它的电容量受温度.电压.时间变化影响大. Y5V贴片电容特性 具有较差的电容量稳定性,在-25℃-85℃工作温度范围内,温 ...
- 宣布正式发布 Windows Azure Notification Hub,新增 SQL Server AlwaysOn 可用性组侦听器支持
今天,我们非常高兴地宣布,针对使用 Windows Azure 的移动和企业开发人员推出一些新功能.这些新功能可以减少构建移动应用程序的开发时间和成本,并能帮助企业开发人员实现高可用性和全球业务连续性 ...
- VS2010/MFC常用控件:图片控件Picture Control
图片控件Picture Control 本节主要讲一种简单实用的控件,图片控件Picture Control.我们可以在界面某个位置放入图片控件,显示图片以美化界面. 图片控件简介 图片控件和前面讲到 ...
- js中this指向问题
1.在全局范围内使用this的时候 它指向的是全局对象 this Window {top: Window, window: Window, location: Location, external: ...
- 与html相关的知识点整理
梳理html时发现的一些问题.总结一下,答案大都从网上找来. 一.html 与 htm 的区别 没有本质的区别..htm是在win32时代,系统只能识别3位扩展名时使用的.现在一般都使用.html. ...
- AngularJS Directive 学习笔记
指令 Directive 指令要点 大漠老师的教学节点 解析最简单的指令 hello: 匹配模式 restrict 解析最简单的指令 hello: template.tempmlateUrl.$tem ...
- Android应用开发基础篇(8)-----SurfaceView
链接地址:http://www.cnblogs.com/lknlfy/archive/2012/02/25/2368069.html 一.概述 SurfaceView也是一个用来画图的部件,不过由于它 ...
- 【转】Qt Mode/View
1.view与Widget 在UI中,最常用的就是list/grid/tree了(在Qt中,grid被称为table).尤其是做那些数据库相关的程序,可能每个界面都要用到 list或grid.在Qt中 ...
- CUG 数学进阶
题目链接:http://acm.cug.edu.cn/JudgeOnline/contest.php?cid=1047 . . . I 题目链接:http://acm.cug.edu.cn/Judge ...