文字淡出效果
来源:互联网 发布:python中文注释报错 编辑:程序博客网 时间:2024/06/06 01:22
1、设置动画
模仿一些软件文字慢慢淡出效果,主要用到移动动画(负责view移动),缩放动画(负责view在移动过程中不断的缩小)和透明度动画(在移动的过程中减少文字透明度)。
<span style="font-family:Comic Sans MS;font-size:14px;">int[] location = new int[2];tv_score_animation.getLocationInWindow(location); //获取当前view的位置</span>
<span style="font-family:Comic Sans MS;font-size:14px;">private void animation(final int addscore, int[] location) {TranslateAnimation translateAnimation = new TranslateAnimation(0, 0, 0,-location[1]);translateAnimation.setDuration(800);tv_score_animation.setText("+" + addscore);// 缩放时以x和y坐标轴的中心点开始缩放final Animation scaleAnimation = new ScaleAnimation(1f, 0.2f, 1f, 0.2f,Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,0.5f);// 设置尺寸变化动画final Animation alphaAnimation = new AlphaAnimation(1.0f, 0f); // 设置透明度变化动画scaleAnimation.setDuration(800);alphaAnimation.setDuration(800);AnimationSet set = new AnimationSet(true); // 创建动画集对象set.addAnimation(scaleAnimation); // 添加尺寸变化动画set.addAnimation(alphaAnimation); // 添加透明度渐变动画set.addAnimation(translateAnimation); // 添加位置变化动画set.setFillAfter(true); // 停留在最后的位置set.setFillEnabled(true);tv_score_animation.setAnimation(set); // 设置动画set.startNow(); // 启动动画}</span>
2、布局文件
这里使用了两个textview控件,一个用于移动,一个则固定在原有的位置记录当前的值。这两个控件所表示的值是不同的,这样就会有移动的textview是从固定的textview中慢慢的退出的。
<span style="font-family:Comic Sans MS;font-size:14px;"> <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" > <TextView android:id="@+id/tv_score_animation" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:gravity="center_horizontal" android:textColor="#aa000000" android:textSize="50sp" /> <TextView android:id="@+id/tv_score" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:gravity="center_horizontal" android:text="50" android:textColor="#aa000000" android:textSize="50sp" /> </RelativeLayout></span>
0 0
- 文字淡出效果
- 文字淡出效果
- flex 文字淡入淡出效果
- jQuery标题文字淡入淡出显示效果
- 新浪微博首页文字淡入淡出滚动效果
- 基于jquery实现的文字淡入淡出效果
- 使用HTML5画布生成文字淡入淡出效果
- 淡出效果
- Jquery仿新浪微博图片文字列表淡进淡出上下滚动效果
- 页面淡入淡出效果
- 淡入、淡出效果
- 淡入淡出效果
- 窗口淡入淡出效果
- 窗体淡入淡出效果
- jquery淡入淡出效果
- 实现淡入淡出效果
- 图片淡出效果
- 窗体淡入淡出效果
- poj3292--Semi-prime H-numbers(数论篇2)
- Java连接SQL Server 2012
- 子集和问题
- 人生的际遇,请,未必会来;躲,未必能免
- 线程学习一
- 文字淡出效果
- 自定义org.apache.commons.beanutils的类型转换器
- uva 11729 Commando War(贪心算法)
- (转载)linux命令之四十五crontab命令
- 滤波电容、去耦电容、旁路电容作用及区别
- uva10562 - Undraw the Trees 入门经典II 第六章数据结构基础 例题6-17
- CentOS开机自动运行程序的脚本
- apache访问根目录 配置作用域
- Objective-C的内存管理MRC与ARC