android的ViewPager和Animation有些使用(二)
Animation部分
android的animation分scale,rotate,tranlateAnimation,alpha这些类型的
start animation这里有几种方法:
<span style="white-space:pre"> </span> t1_icon1.setImageResource(R.drawable.t1_frame_animation); //<span style="font-family: Arial, Helvetica, sans-serif;">t1_frame_animation这个动画是放在drawable下的</span>
t1_icon1_animationDrawable = (AnimationDrawable) t1_icon1
.getDrawable();
t1_icon1_animationDrawable.start();
t1_frame_animation的xml 是两种图案的交替显示:
<?xml version="1.0" encoding="UTF-8"? >
<animation-list android:oneshot="false"
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:duration="200" android:drawable="@drawable/tutorial1_icon1" />
<item android:duration="200" android:drawable="@drawable/tutorial1_icon2" />
</animation-list>
另一种是放在anim目录下:
<span style="white-space:pre"> </span> Animation tutorail_rotate = AnimationUtils.loadAnimation(MainActivity.this, R.anim.tutorail_rotate);
t1_icon2.startAnimation(tutorail_rotate);
<?xml version="1.0" encoding="UTF-8"?>
<set
xmlns:android="http://schemas.android.com/apk/res/android">
<scale android:interpolator="@android:anim/accelerate_decelerate_interpolator" android:duration="800" android:pivotX="50.0%" android:pivotY="50.0%" android:fillAfter="false" android:fromXScale="0.0" android:toXScale="1.2" android:fromYScale="0.0" android:toYScale="1.2" />
<rotate android:duration="3000" android:fromDegrees="0.0" android:toDegrees="359.0" android:pivotX="50.0%" android:pivotY="50.0%" android:repeatCount="infinite" />
</set>
当中: pivotX为属性为动画相对于物件的X坐标的開始位置,一般填50%,就是View的中心点,repeateCount的意思是反复的次数
另一种为LayoutAnimation:
直接在xml中载入
对于这种引导页面:
第一页的动画是:
t1_icon1.setImageResource(R.drawable.t1_frame_animation);
t1_icon1_animationDrawable = (AnimationDrawable) t1_icon1
.getDrawable();
t1_icon1_animationDrawable.start(); Animation tutorail_rotate = AnimationUtils.loadAnimation(MainActivity.this, R.anim.tutorail_rotate);
t1_icon2.startAnimation(tutorail_rotate);
Animation tutorail_scalate = AnimationUtils.loadAnimation(MainActivity.this, R.anim.tutorail_scalate);
t1_fixed.startAnimation(tutorail_scalate); Animation tutorail_bottom = AnimationUtils.loadAnimation(MainActivity.this, R.anim.tutorail_bottom);
t1_next.startAnimation(tutorail_bottom);
<pre name="code" class="java" style="line-height: 18px;">tutorail_scalate<span style="font-family: Consolas, 'Courier New', Courier, mono, serif;">为:</span>
<?xml version="1.0" encoding="UTF-8"? >
<set
xmlns:android="http://schemas.android.com/apk/res/android">
<scale android:interpolator="@android:anim/accelerate_decelerate_interpolator" android:duration="1000" android:pivotX="50.0%" android:pivotY="50.0%" android:fillAfter="false" android:fromXScale="0.0" android:toXScale="1.1" android:fromYScale="0.0" android:toYScale="1.1" />
</set>
<span style="font-family: Consolas, 'Courier New', Courier, mono, serif;">tutorail_bottom为:</span>
<pre name="code" class="java" style="line-height: 18px;"><pre name="code" class="html"><?xml version="1.0" encoding="UTF-8"?>
<set android:repeatMode="reverse"
xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:duration="1000" android:repeatCount="infinite" android:fromXDelta="0.0" android:toXDelta="0.0" android:fromYDelta="-15.0" android:toYDelta="20.0" />
<alpha android:duration="1000" android:repeatCount="infinite" android:fromAlpha="1.0" android:toAlpha="0.3" />
</set>
</pre><pre code_snippet_id="426826" snippet_file_name="blog_20140715_11_1748017" name="code" class="html">第一页的Layout为:
<pre name="code" class="html"><?xml version="1.0" encoding="UTF-8"?>
<LinearLayout android:gravity="center" android:orientation="vertical" android:background="@android:color/white" android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView android:id="@+id/t1_fixed" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="15.0dip" android:src="@drawable/tutorial1_fixed" />
<RelativeLayout android:id="@+id/center_layout" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_centerInParent="true">
<ImageView android:id="@+id/t1_icon1" android:background="@drawable/t1_frame_animation" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="180.0dip" android:layout_marginTop="53.0dip" />
<ImageView android:id="@+id/t1_icon2" android:visibility="visible" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="30.0dip" android:src="@drawable/tutorial1_icon3" android:layout_below="@id/t1_icon1" android:layout_centerHorizontal="true" />
<ImageView android:id="@+id/t1_static" android:visibility="visible" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/tutorial1_static" android:layout_centerHorizontal="true" />
<ImageView android:id="@+id/t1_text" android:visibility="visible" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="10.0dip" android:src="@drawable/tutorial1_text" android:layout_below="@id/t1_static" android:layout_centerHorizontal="true" />
</RelativeLayout>
<ImageView android:id="@+id/t1_next" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="20.0dip" android:src="@drawable/tutorial_next" />
</LinearLayout>
</pre><pre code_snippet_id="426826" snippet_file_name="blog_20140715_14_7418428" name="code" class="html">第4页的火箭是採用:
<span style="white-space:pre"> </span>t3_icon6.setImageResource(R.drawable.t3_frame_animation);
<span style="white-space:pre"> </span>AnimationDrawable t3_icon6_animationDrawable = (AnimationDrawable) t3_icon6.getDrawable();
<span style="white-space:pre"> </span>t3_icon6_animationDrawable.start();
</pre><pre code_snippet_id="426826" snippet_file_name="blog_20140715_17_3437503" name="code" class="html"><pre name="code" class="html" style="line-height: 18px;">t3_frame_animation为:
<?xml version="1.0" encoding="UTF-8"?>
<animation-list android:oneshot="false"
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:duration="70" android:drawable="@drawable/rocket_long" />
<item android:duration="70" android:drawable="@drawable/rocket_middle" />
<item android:duration="70" android:drawable="@drawable/rocket_short" />
</animation-list>
第四页的摆动动画这样写:
int pivot = Animation.RELATIVE_TO_SELF;
<span style="white-space:pre"> </span>CycleInterpolator interpolator = new CycleInterpolator(3.0f);
<span style="white-space:pre"> </span>RotateAnimation animation = new RotateAnimation(0, 10, pivot, 0.47f, pivot, 0.05f);
<span style="white-space:pre"> </span>animation.setStartOffset(500);
<span style="white-space:pre"> </span>animation.setDuration(3000);
<span style="white-space:pre"> </span>animation.setRepeatCount(1);// Animation.INFINITE
<span style="white-space:pre"> </span>animation.setInterpolator(interpolator);
<span style="white-space:pre"> </span>t4_icon1.startAnimation(animation);
android的ViewPager和Animation有些使用(二)的更多相关文章
- Android Animation学习(二) ApiDemos解析:基本Animators使用
Android Animation学习(二) ApiDemos解析:基本Animatiors使用 Animator类提供了创建动画的基本结构,但是一般使用的是它的子类: ValueAnimator.O ...
- android开发之Animations的使用(二)
android开发之Animations的使用(二) 本博文主要讲述的是android开发中的animation动画效果的使用,和上一篇博文不同的是,此次四种动画效果,主要使用的是xml文件实现的,提 ...
- android下ViewPager的使用,带下部选项栏的切换动画
(文章针对类似我这种初学者,大神看到不要嘲笑) 演示 我的规矩是先上GIF动画效果(Linux下用转的GIF,清晰度还可以但是不知道为什么放博客上,界面会这么大): 代码: android中有View ...
- Android中ViewPager实现滑动条及与Fragment结合的实例教程
ViewPager类主要被用来实现可滑动的视图功能,这里我们就来共同学习Android中ViewPager实现滑动条及与Fragment结合的实例教程,需要的朋友可以参考下 自主实现滑动指示条先上一个 ...
- Android 8.1 关机充电动画(二)Uboot模式
system:Android 8.1 platform:RK3326/PX30 uboot kernel Android 8.1 关机充电动画(一)模式选择 Android 8.1 关机充电动画(二) ...
- Android中viewPager的一两点使用
Android中viewPager的一两点使用 viewPager是谷歌官方提供的一种方便实现页面滑动效果的控件,可以直接使用也可以和fragment联合使用.这里只简单说下直接使用. 使用viewP ...
- 最牛逼android上的图表库MpChart(二) 折线图
最牛逼android上的图表库MpChart二 折线图 MpChart折线图介绍 MpChart折线图实例 MpChart效果 最牛逼android上的图表库MpChart(二) 折线图 最近工作中, ...
- Android中ViewPager+Fragment取消(禁止)预加载延迟加载(懒加载)问题解决方案
转载请注明出处:http://blog.csdn.net/linglongxin24/article/details/53205878本文出自[DylanAndroid的博客] Android中Vie ...
- android之ViewPager
在android中ViewPager是非常常用的控件.它在android.support.v4.view.ViewPager下.你们自己可以进http://developer.android.com/ ...
随机推荐
- jQuery为啥要提供一个load()方法?
上午的时候,找个闲暇事件整理之前整理的一些关于jQuery的东西,看到了一个之前做的jQuery的$(document).ready()与window.onload()方法的比較. 上面两个方法最重要 ...
- 从源代码角度分析ViewStub 疑问与原理
一.提出疑问 ViewStub比較简单.之前文章都提及到<Android 性能优化 三 布局优化ViewStub标签的使用>.可是在使用过程中有一个疑惑,究竟是ViewStub上设 ...
- Nubia Z5S 基于官方H207/4.4内核的Mokee4.4.4 RC3.2 (2014.7.31修复呼吸灯(能亮依旧不能呼吸))
特别感谢 yun3195 和 轻描淡写Yhw 帮忙測试 转帖请务必注明本链接地址: http://blog.csdn.net/syhost/article/details/36444259 此ROM ...
- GrabCut--Opencv篇
最近因为工作需要,需要实现一个Grabcut函数.Opencv已经提供此函数,今天把opencv的例程拿出来跑了一下,对于简单的背景实现效果还不错. OpenCV中的GrabCut算法是依据<& ...
- WebSocket是一种协议
WebSocket,并非HTML 5独有,WebSocket是一种协议.只是在handshake的时候,发送的链接信息头和HTTP相似.HTML 5只是实现了WebSocket的客户端.其实,难点在于 ...
- hdu2066一个人的旅行
枚举全部相邻城市,作为起点,多次spfa,然后每次在想去的城市中找出spfa后的距离起点最短的花费时间 #include <iostream> #include <cstring&g ...
- ActiveX 暴漏你全部信息的可怕的插件!
近期在项目中常常接触ActiveX控件,对于这个名词相信仅仅要是上网看视频的用户一定都会遇到adobe更新或者载入的提示,这就是一个ActiveX控件.一直以为Active控件是处理复杂的页面逻辑提供 ...
- 介绍linux下Source Insight强大代码编辑器sublime_text_3
背景 1 一. 运行环境 1 二.安装环境配置 1 三.创建快捷方式 1 四.配置全局环境 2 五.操作界面 3 背景 在windows操作系统系统下,文本代码编辑器众多,各路英雄豪杰争相写了许多强大 ...
- ThinkPHP框架视图详细介绍 View 视图--模板(九)
原文:ThinkPHP框架视图详细介绍 View 视图--模板(九) 视图也是ThinkPHP使用的核心部分: 一.模板的使用 a.规则 模板文件夹下[TPL]/[分组文件夹/][模板主题文件夹/]和 ...
- [Android学习笔记]ScrollView的使用
竖直滚动使用ScrollView 水平滚动使用HorizontalScrollView 如果需要禁止ScrollView的滚动,则需要扩展ScrollView类,重写onTouchEvent方法.