- 浏览: 5778818 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (890)
- WindowsPhone (0)
- android (88)
- android快速迭代 (17)
- android基础 (34)
- android进阶 (172)
- android高级 (0)
- android拾遗 (85)
- android动画&效果 (68)
- Material Design (13)
- LUA (5)
- j2me (32)
- jQuery (39)
- spring (26)
- hibernate (20)
- struts (26)
- tomcat (9)
- javascript+css+html (62)
- jsp+servlet+javabean (14)
- java (37)
- velocity+FCKeditor (13)
- linux+批处理 (9)
- mysql (19)
- MyEclipse (9)
- ajax (7)
- wap (8)
- j2ee+apache (24)
- 其他 (13)
- phonegap (35)
最新评论
-
Memories_NC:
本地lua脚本终于执行成功了,虽然不是通过redis
java中调用lua脚本语言1 -
ZHOU452840622:
大神://处理返回的接收状态 这个好像没有监听到 遇 ...
android 发送短信的两种方式 -
PXY:
拦截部分地址,怎么写的for(int i=0;i<lis ...
判断是否登录的拦截器SessionFilter -
maotou1988:
Android控件之带清空按钮(功能)的AutoComplet ...
自定义AutoCompleteTextView -
yangmaolinpl:
希望有表例子更好。。。,不过也看明白了。
浅谈onInterceptTouchEvent、onTouchEvent与onTouch
已不再推荐补间动画,请使用属性动画;
http://blog.csdn.net/guolin_blog/article/details/43536355
http://blog.csdn.net/guolin_blog/article/details/43816093
onCreate()中:
点击Imageview启动动画:
添加动画监听,在AnimationEnd的时候切换动画:
布局,让ImageView一开始的时候在屏幕右边:
本实例只是实现连续动画的一种简单办法,针对本例子应该还有更简单的方法.
///////////////////////////////////////////////////////////////////
//下面是anroid Api demo自带的一个shake(摇头)效果
///////////////////////////////////////////////////////////////////
anim/shake.xml
anim/cycle_7.xml
Android混合型动画AnimationSet
附:android中所有的interpolator
android平台提供了如下的interpolater
AccelerateDecelerateInterpolator
AccelerateInterpolator
CycleInterpolator
DecelerateInterpolator
LinearInterpolator
AnticipateInterpolator
AnticipateOvershootInterpolator
BounceInterpolator
OvershootInterpolator
这些interpolater实现的是
android.view.animation.Interpolator接口
该接口只有一个方法
getInterpolation(float num)
也就是不同的interpolater计算出的值不一样,比如:
public float getInterpolation(float input)
{
if (mFactor == 1.0f)
{
return (float)(input * input);
}
else
{
return (float)Math.pow(input, 2 * mFactor);
}
}
当输入的值为1时候,那么返回值是平方,否则返回立方的值。
其实interpolator是按照这种方式计算的
This interpolator’s goal is to provide a multiplication factor given a time interval
based on a hyperbolic curve。
基于双曲线计算时间的间隔,进行相关的动画处理。
比如常用的accelerator_interpolator其xml定义的结构为:
<accelerator xmlns:android="http://schemas.android.com/apk/res/android"
factor="1" /> 其乘数为1;基于此进行计算。
在大家学习的过程中建议大家多看英文的东西,这样会事半功倍的。
http://blog.csdn.net/guolin_blog/article/details/43536355
http://blog.csdn.net/guolin_blog/article/details/43816093
onCreate()中:
iv=(ImageView)this.findViewById(R.id.iv); iv.setTag("toRight"); iv.setOnClickListener(listener); ani_0 = new TranslateAnimation( Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, -1.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f); ani_1= new TranslateAnimation( Animation.RELATIVE_TO_PARENT, -1.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f); ani_0.setInterpolator(new AccelerateDecelerateInterpolator()); ani_0.setDuration(1000); ani_0.setFillEnabled(true); ani_0.setFillAfter(true); ani_0.setAnimationListener(animationListener); ani_1.setInterpolator(new AccelerateDecelerateInterpolator()); ani_1.setDuration(1000); ani_1.setFillEnabled(true); ani_1.setFillAfter(true); ani_1.setAnimationListener(animationListener);
点击Imageview启动动画:
OnClickListener listener=new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub switch (v.getId()) { case R.id.iv: iv.startAnimation(ani_0); break; } }
添加动画监听,在AnimationEnd的时候切换动画:
final AnimationListener animationListener = new AnimationListener() { @Override public void onAnimationEnd(Animation animation) { if (animation == ani_0) { iv.startAnimation(ani_1); } if (animation == ani_1) { iv.startAnimation(ani_0); } } @Override public void onAnimationRepeat(Animation animation) { // TODO Auto-generated method stub } @Override public void onAnimationStart(Animation animation) { // TODO Auto-generated method stub } };
布局,让ImageView一开始的时候在屏幕右边:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <ImageView android:id="@+id/iv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/search2" android:scaleType="fitCenter" android:layout_gravity="right" /> </LinearLayout>
本实例只是实现连续动画的一种简单办法,针对本例子应该还有更简单的方法.
///////////////////////////////////////////////////////////////////
//下面是anroid Api demo自带的一个shake(摇头)效果
///////////////////////////////////////////////////////////////////
import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.animation.Animation; import android.view.animation.AnimationUtils; public class Animation1 extends Activity implements View.OnClickListener { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.animation_1); View loginButton = findViewById(R.id.login); loginButton.setOnClickListener(this); } public void onClick(View v) { Animation shake = AnimationUtils.loadAnimation(this, R.anim.shake); findViewById(R.id.pw).startAnimation(shake); } }
anim/shake.xml
<?xml version="1.0" encoding="utf-8"?> <translate xmlns:android="http://schemas.android.com/apk/res/android" android:fromXDelta="0" android:toXDelta="10" android:duration="1000" android:interpolator="@anim/cycle_7" />
anim/cycle_7.xml
<?xml version="1.0" encoding="utf-8"?> <cycleInterpolator xmlns:android="http://schemas.android.com/apk/res/android" android:cycles="7" />
Android混合型动画AnimationSet
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // 要使用findViewById, 一定要使用layout / *.xml 做为使用者介面 setContentView( R.layout.main ); // 取得UI 介面中的View 物件 // 取得View 物件后,再透过转换成实际的物件 ImageView ivPic = (ImageView)this.findViewById(R.id.widget10); //底图 ImageView iv = (ImageView)this.findViewById(R.id.widget28); // 设定ImageView 的图片来源 ivPic.setImageResource( R.drawable.a2 ); iv.setImageResource( R.drawable.icon ); // 透明度动画设定(startAlpha, endAlpha) Animation am1 = new AlphaAnimation ( 1, 0 ); // 动画开始到结束的执行时间(1000 = 1 秒) am1. setDuration ( 2000 ); // 动画重复次数(-1 表示一直重复) am1. setRepeatCount ( -1 ); // 旋转动画设定(startAngle, endAngle, rotateX, rotateY) Animation am2 = new RotateAnimation ( 0, 360, 30, 30 ); // 动画开始到结束的执行时间(1000 = 1 秒) am2. setDuration ( 2000 ); // 动画重复次数(-1 表示一直重复) am2. setRepeatCount ( -1 ); // 动画集合 AnimationSet am = new AnimationSet ( false ); am. addAnimation ( am1 ); am. addAnimation ( am2 ); // 图片配置动画 iv. setAnimation (am); // 动画开始 am. startNow (); }
附:android中所有的interpolator
android平台提供了如下的interpolater
AccelerateDecelerateInterpolator
AccelerateInterpolator
CycleInterpolator
DecelerateInterpolator
LinearInterpolator
AnticipateInterpolator
AnticipateOvershootInterpolator
BounceInterpolator
OvershootInterpolator
这些interpolater实现的是
android.view.animation.Interpolator接口
该接口只有一个方法
getInterpolation(float num)
也就是不同的interpolater计算出的值不一样,比如:
public float getInterpolation(float input)
{
if (mFactor == 1.0f)
{
return (float)(input * input);
}
else
{
return (float)Math.pow(input, 2 * mFactor);
}
}
当输入的值为1时候,那么返回值是平方,否则返回立方的值。
其实interpolator是按照这种方式计算的
This interpolator’s goal is to provide a multiplication factor given a time interval
based on a hyperbolic curve。
基于双曲线计算时间的间隔,进行相关的动画处理。
比如常用的accelerator_interpolator其xml定义的结构为:
<accelerator xmlns:android="http://schemas.android.com/apk/res/android"
factor="1" /> 其乘数为1;基于此进行计算。
在大家学习的过程中建议大家多看英文的东西,这样会事半功倍的。
发表评论
-
ViewPager引导页根据滑动渐变背景色
2017-03-31 09:38 28151、主要依赖: compile'com.android.su ... -
Android 新推出基于物理的动画库SpringAnimation,完全诠释什么叫做弹簧效果
2017-03-30 10:38 2572Android 最近推出一个新的基于物理学的动画支持库,命名为 ... -
一个比较强大的提供各种形状的ImageView
2016-12-26 09:54 2933github上比较老的项目了,但是还是比较好用的。 各种形状总 ... -
PhotoView点击放大图片效果
2016-12-21 10:13 6051使用的PhotoView是这个版本的,比较小巧,很好用,比gi ... -
仿微信页面切换图标颜色渐变效果
2015-11-23 14:54 4418主要是提供一种思路,一般来书,类似效果无非就是在Canvas, ... -
把任意Drawable转换成基于progress填充的drawable
2015-11-11 16:29 2749把任意Drawable转换成基于progress填充的draw ... -
一个用来设置警示View 的呼吸式背景颜色的工具类BreathingViewHelper
2015-10-10 14:03 3037一个简单的小工具类,用来设置警示 View 的呼吸式背景颜色 ... -
单手操作图片控件 镜像、置顶、缩放、移动:StickerView
2015-10-08 11:21 3167单手操作图片控件 镜像、置顶、缩放、移动 impo ... -
图片浏览zoom效果
2015-10-08 11:05 1792不仅实现了Lollipop中打开新的activity 的zoo ... -
Android App状态栏变色:ColorfulStatusBar
2015-09-24 12:38 9909适用于版本大于等于19以上。 import android ... -
PathView实现炫酷SVG动画
2015-08-25 09:23 4403解析SVG,需要将一个androidsvg.jar包含进lib ... -
LinearLayout增加divider分割线
2015-08-13 14:58 11051在android3.0及后面的版本在LinearLayout里 ... -
Android换肤白天/夜间模式的框架
2015-07-29 15:36 2933Android换肤/夜间模式的Android框架,配合them ... -
使用ActivityOptions做Activity切换动画
2015-04-10 11:02 6576不知道大家有没有注意到startActivity(Intent ... -
一个不错的ArcMenu
2015-01-23 10:34 3905ArcMenu这种效果现在很多人都实现了 而且代码质量也 ... -
使用ScheduledExecutorService延时关闭一个全屏的对话框
2014-12-29 16:38 4371自定义style,设置全屏属性 <resources ... -
让View只显示下边框
2014-10-23 17:13 3965下面的代码是实现一个带边框的xml,很常见 <?xm ... -
让一张图片从模糊慢慢变清晰动画过程
2014-01-27 16:38 9251import java.io.IOExcepti ... -
ListView,GridView之LayoutAnimation特殊动画的实现
2013-05-24 11:23 34368LayoutAnimation干嘛用的?不知道的话网上搜一下。 ... -
食神摇摇中图片的晃动效果
2013-04-27 11:45 5453可以是这样子实现滴: btn_shake=(Image ...
相关推荐
让两个imageView上的图片实现动画互换并且让互换后的Imageview位置也互换
android自定义ImageView实现旋转动画
通过图片的url获取到图片,并显示到imageview中,本实例中选择的图片的百度官网的logo。仅提供一种获取网络图片的方法。
安卓ImageView水平方向上随着手指来回移动
自定义带边框ImageView
1.在listView中,当点击ImageView时,EditText+1,当点击mageView1时,EditText-1。
DismissibleImageView 点击ImageView能够扩展至全屏,然后通过拉到屏幕边缘恢复原状
一个ImageView子类,它在图像上绘制一个或多个可扩展的、可旋转的、可伸缩的文本。
俩个imageview拖动互换俩张图片,也是拼图游戏的部分原理;
Diagonal ImageView 一个简单的imageview,允许您轻松创建对角切割视图
在imageview上的指定位置添加另一个iamgeview,并实现等比例缩放,图片自适应
Android平台ImageView拖拽实例,点击ImageView,可随着随着触摸轨迹随意移动,绝对超值。
imageview通过手势缩放。imageview通过手势放大缩小拖拽,放大超出屏幕
使用ViewDragHelp实现ImageView拖动超过屏幕1/2回到屏幕左边,否则到右边,还有一个就是还能实现点击的效果
圆形的ImageView可以完全替代安卓系统默认的ImageView,内附详细demo。
手势缩放的Imageview
一个可指定任意角为圆角的ImageView,简单好用,欢迎下载 原博客地址 https://blog.csdn.net/Sure_Min/article/details/79102226
Android中ImageView实现平铺多张图片Android中实现平铺图片有两种方式:在drawable中定义平铺的Bitmap然后在ImageView中引
driveimageview First things first ...The example application is available at the play store: General idea The idea of this android library is to give the possibility to display two texts inside the ...
实验三 ImageView和Switch的使用