Implement a TextView with an animation in its left side
In my case, I want to write a TextView with an animation in its left side.
ImageView + TextView could work but it’s not frugal enough.
TextView with drawableLeft would be the best option.
1 |
<TextView |
But above implementation just show a icon in the left of TextView, not an animation.
How to show an animation instead of a icon?
Assume you have 4 pictures which would be an animation if display them one after one. Then define animation xml in res/anim folder in your project.
loading_animation.xml:
1 |
<animation-list xmlns:android=”http://schemas.android.com/apk/res/android” |
“android:oneshot” determines whether or not play the animation just once.
“android:duration” determines the duration of pictures switching.
Then in layout xml, use above animation like this:
1 |
<TextView |
Bingo? no, no, no, the animation can not switching yet.
You need to do more.
In java/Activity code, you must get the animation drawable and start it.
1 |
Drawable[] draws = locateAreaTextView.getCompoundDrawables(); |
In above, we get index 0 of the drawable array since drawableLeft is in 0 position of the array.
Now, the animation works. But there is one more trap.
If you put above codes in onCreate() of Activity, draws will be a [null, null, null, null] array.
You must put it in onResumse() of Activity.
Implement a TextView with an animation in its left side的更多相关文章
- 用开源项目ExpandableTextView打造可以下拉扩展的TextView
这次还是用开源项目来实现效果,我个人觉得上面的这个效果还是很赞的.于是就记录下如何实现这个效果,其实相当简单.这就是开源项目写的好的例子,整个开源项目的代码十分清晰,逻辑和代码结构都很棒,接入自己的工 ...
- IOS 开发教程
http://www.raywenderlich.com/category/ios http://www.raywenderlich.com/50310/storyboards-tutorial-in ...
- 【转】Android 实现蘑菇街购物车动画效果
原文出处:http://blog.csdn.net/wangjinyu501/article/details/38400479 1.思路 目前想到两种方式实现这种效果,一是使用Tween动画,直截 ...
- 手势识别官方教程(4)在挑划或拖动手势后view的滚动用ScrollView和 HorizontalScrollView,自定义用Scroller或OverScroller
简单滚动用ScrollView和 HorizontalScrollView就够.自定义view时可能要自定义滚动效果,可以使用 Scroller或 OverScroller Animating a S ...
- android程序启动画面之Splash总结[转]
方法一: 很多应用都会有一个启动界面.欢迎画面慢慢隐现,然后慢慢消隐.实现这种效果的方法有两种(暂时只发现两种)1.使用两个Activity,程序启动时候load第一张Activity,然后由tick ...
- 使用CAShapeLayer来实现圆形图片加载动画[译]
原文链接 : How To Implement A Circular Image Loader Animation with CAShapeLayer 原文作者 : Rounak Jain 译文出自 ...
- Android:简单的弹幕效果达到
首先,效果图.分类似至360检测到的骚扰电话页面: 布局非常easy,上面是一个RelativeLayout,以下一个Button. 功能: (1)弹幕生成后自己主动从右側往左側滚动(Translat ...
- Android 实现蘑菇街购物车动画效果
版本号:1.0 日期:2014.8.6 版权:© 2014 kince 转载注明出处 使用过蘑菇街的用户基本上都知道有一个增加购物车的动画效果,此处不详细描写叙述想知道的能够去下载体验一下. 1 ...
- android---动画入门(一)
android 动画分为两类,View Animation(视图动画)和property Animation(属性动画),View Animation(视图动画)包含了Tween Animation和 ...
随机推荐
- ubuntu下安装TexLive和Texmaker
也可以参考ubuntu14.04配置中文latex完美环境(texlive+texmaker+lyx) 设置中文字体的时候参考ubuntu 下安装 texlive 并设置 ctex 中文套装 1.首先 ...
- Tomcat 用户访问控制
要设置Tomcat下的Host都有哪些ip能访问,可以在conf/server.xml的相应Host元素内加Value标签,示例: <Valve className="org.apac ...
- 使用ASP.NET Web Api构建基于REST风格的服务实战系列教程【九】——API变了,客户端怎么办?
系列导航地址http://www.cnblogs.com/fzrain/p/3490137.html 前言 一旦我们将API发布之后,消费者就会开始使用并和其他的一些数据混在一起.然而,当新的需求出现 ...
- CodeForces - 699B One Bomb
题目地址:http://codeforces.com/contest/699/problem/B 题目大意: 一个矩阵,内容由‘.’和‘*’组成(‘.’ 空,‘*’ 代表墙),墙分布在不同位置,现找出 ...
- 兼容IE的写法收集||bug修复
这篇文章实时更新 属于IE的专属写法 其中,S表示Standards Mode即标准模式,Q表示Quirks Mode,即兼容模式 hack 示例 IE6(S) IE6(Q) IE7(S) IE7(Q ...
- 项目管理知识框架PMBOK(文字版)
项目管理知识框架PMBOK 项目整体管理[I](Integration) 1. 制定项目章程(Develop Project Charter) 2. 制定项目初步范围说明书(Develop Pre ...
- Android studio 的初始设置
[声明] 欢迎转载,但请保留文章原始出处→_→ 生命壹号:http://www.cnblogs.com/smyhvae/ 文章来源:http://www.cnblogs.com/smyhvae/p/4 ...
- Lua 之os库
标准os库 os.rename(oldname, newname) 文件重命名: os.remove(filename) 删除一个文件 os.execute(cmd) os.execute可运行一条系 ...
- JavaScript正则表达式方法总结
str.match(reg) 1.reg没有全局标志g,match将只执行一次匹配.匹配成功返回一个数组,arr = [$0,$1,$2,...,index,str],匹配失败返回null. arr中 ...
- Orchard源码分析(6):Shell相关
概述在Orchard中,提出子站点(Tenant)的概念,目的是为了增加站点密度,即一个应用程序域可以有多个子站点. Shell是子站点(Tenant)级的单例,换句话说Shell代表了子站点.对比来 ...