淘宝的购物车==> ”抛物线“
来源:互联网 发布:jre windows x64 编辑:程序博客网 时间:2024/05/03 11:28
属性动画
1, ObjectAnimator
2, ValueAnimator
3, PropertyValuesHolder
4, TypeEvaluator 估值器 (改变速度的)
5,Interpolator 差值器 (计算速度的)
抛物线的代码
package com.example.animator;import android.animation.ObjectAnimator;import android.animation.PropertyValuesHolder;import android.animation.TypeEvaluator;import android.animation.ValueAnimator;import android.animation.ValueAnimator.AnimatorUpdateListener;import android.app.Activity;import android.graphics.PointF;import android.os.Bundle;import android.view.Menu;import android.view.MenuItem;import android.view.View;import android.view.animation.BounceInterpolator;import android.view.animation.Interpolator;import android.widget.ImageView;public class MainActivity extends Activity { private ImageView iv; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); iv = (ImageView)findViewById(R.id.iv_image); } public void CLick(View v) { Interpolator /*ObjectAnimator oa = ObjectAnimator.ofFloat(iv, "translationY",0f, 1000f); oa.setDuration(5000); oa.setInterpolator(new BounceInterpolator()); oa.start();*/ ValueAnimator valueAnimator = new ValueAnimator(); valueAnimator.setDuration(5000); valueAnimator.setObjectValues(new PointF(0, 0)); final PointF pointF =new PointF(); valueAnimator.setEvaluator(new TypeEvaluator<PointF>() { @Override public PointF evaluate(float fraction, PointF startValue, PointF endValue) { // TODO Auto-generated method stub pointF.x = 100f *(fraction * 5); pointF.y = 10f * 0.5f * 9.8f * (fraction * 5) * (fraction * 5); return pointF; } }); valueAnimator.addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { // TODO Auto-generated method stub PointF f = (PointF) animation.getAnimatedValue(); iv.setX(f.x); iv.setY(f.y); } }); valueAnimator.start(); }}
刷鲜花效果
思路:
1,SVG - Path + PathMeasure
2,属性动画
淘宝上刷案例
package com.example.animator;import android.animation.Animator;import android.animation.AnimatorListenerAdapter;import android.animation.AnimatorSet;import android.animation.ObjectAnimator;import android.animation.TypeEvaluator;import android.animation.ValueAnimator;import android.animation.ValueAnimator.AnimatorUpdateListener;import android.app.Activity;import android.graphics.PointF;import android.os.Bundle;import android.view.View;import android.widget.Button;import android.widget.ImageView;/** * 淘宝的 * @author 作者: songli * QQ : 2734030745 * 时间 : 2017年6月14日 上午12:04:10 * 邮箱 : 15850774503@163.com */public class MainActivity extends Activity { private View first_view; private View second_view; private Button bt; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); first_view = findViewById(R.id.first); second_view = findViewById(R.id.second); bt = (Button)findViewById(R.id.bt); } public void startfirstAnim(View v) { //显示first view :1, 透明度动画 2,缩放动画 ObjectAnimator firstAlphaAnim = ObjectAnimator.ofFloat(first_view, "alpha", 1.0f, 0.7f ); firstAlphaAnim.setDuration(300); //旋转 (xuan)动画1 ObjectAnimator firstRotationXanim = ObjectAnimator.ofFloat(first_view, "rotationX", 0f, 20f); firstRotationXanim.setDuration(300); //再旋转回来 ObjectAnimator firstResumeRotaionXanim = ObjectAnimator.ofFloat(first_view, "rotationX", 20f, 0f ); firstResumeRotaionXanim.setDuration(300); firstResumeRotaionXanim.setStartDelay(300); //延迟第一次 //缩放动画 ObjectAnimator firstScaleXanim = ObjectAnimator.ofFloat(first_view, "scaleX", 1.0f, 0.8f); firstScaleXanim.setDuration(300); ObjectAnimator firstScaleYanim = ObjectAnimator.ofFloat(first_view, "scaleY", 1.0f, 0.8f); firstScaleYanim.setDuration(300); //由于缩放造成有一个距离, 需要平移 ObjectAnimator firstTranslationYAnim = ObjectAnimator.ofFloat(second_view, "translationY",0f, -0.1f * first_view.getHeight() ); firstTranslationYAnim.setDuration(300); //第二个view个和第一个view动画同时开始执行 ObjectAnimator secondTranslationYanim = ObjectAnimator.ofFloat(second_view, "translationY", -0.1f * second_view.getHeight()); secondTranslationYanim.setDuration(300); secondTranslationYanim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { // TODO Auto-generated method stub super.onAnimationStart(animation); second_view.setVisibility(View.VISIBLE); bt.setClickable(false); } }); //动画集 AnimatorSet animset = new AnimatorSet(); animset.playTogether(firstAlphaAnim, firstRotationXanim, firstResumeRotaionXanim, firstScaleXanim, firstScaleYanim, firstTranslationYAnim, secondTranslationYanim); animset.start(); }}
xml文件
<LinearLayout 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" tools:context="${relativePackage}.${activityClass}" > <LinearLayout android:id="@+id/first" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/icon2" android:orientation="vertical"> <Button android:id="@+id/bt" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="显示" android:background="#f00" android:onClick="startfirstAnim"/> </LinearLayout> <ImageView android:id="@+id/second" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" android:src="@drawable/icon1" android:scaleType="fitXY" android:onClick="startSecondAnim" android:visibility="invisible" android:clickable="true"/></LinearLayout>
阅读全文
0 0
- 淘宝的购物车==> ”抛物线“
- 购物车的抛物线运动
- 类似加入购物车的抛物线动画
- 购物车功能抛物线轨迹
- CSS3 抛物线 加入购物车
- CSS3 抛物线 加入购物车
- Jquery购物车抛物线效果
- 加入购物车的抛物线小球运动效果
- 加入购物车的抛物线过程fly插件
- 加入购物车抛物线效果的基本实现(一)
- 实现购物车点击添加的抛物线动画效果
- 商品加入购物车抛物线下坠的动画
- 购物抛物线
- 点餐,购物车抛物线效果
- jquery之抛物线式购物车
- ios 抛物线添加到购物车
- 关于淘宝购物车的界面搭建
- 仿淘宝购物车的实现
- 第四届图灵赛-I、一道不简单的题目(水,读行)
- 多媒体播放器模块
- 决策分析模块
- 关于加密解密
- 网络留言簿
- 淘宝的购物车==> ”抛物线“
- 桌面精灵
- 浅入Https
- Android7.0中文文档 --- CompoundButton
- Spring中的AOP基础
- 短信发送
- git上传本地Intellij idea 项目到github
- 数据分页
- Google-Guice入门介绍