实现炫酷的点赞动画
来源:互联网 发布:淘宝网小女孩连衣裙 编辑:程序博客网 时间:2024/06/05 02:41
先上图
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="wrap_content" android:background="@drawable/orval" android:layout_width="40dp" android:orientation="vertical"> <ImageView android:id="@+id/like" android:layout_width="wrap_content" android:layout_height="40dp" android:background="@drawable/like_10" /> <View android:id="@+id/bottomView" android:layout_width="match_parent" android:layout_height="0dp" /></LinearLayout>
看代码
package com.example.fanday.ipc;import android.animation.ValueAnimator;import android.content.Context;import android.graphics.drawable.AnimationDrawable;import android.support.annotation.Nullable;import android.util.AttributeSet;import android.view.View;import android.widget.FrameLayout;import android.widget.ImageView;/** * Created by fanday on 2017/8/9. */public class LikeView extends FrameLayout implements View.OnClickListener { public LikeView(Context context) { this(context,null,0); } public LikeView(Context context, @Nullable AttributeSet attrs) { this(context, attrs,0); } public LikeView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(); } View bottomView; ImageView like; private void init() { View view = View.inflate(getContext(), R.layout.like_layout, null); this.addView(view); bottomView = view.findViewById(R.id.bottomView); like = (ImageView) view.findViewById(R.id.like); like.setOnClickListener(this); } @Override public void onClick(View v) { final MarginLayoutParams lp = (MarginLayoutParams) bottomView.getLayoutParams(); final ValueAnimator va = ValueAnimator.ofInt(0,100); va.setDuration(1000); va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { int value = (int) animation.getAnimatedValue(); lp.bottomMargin = value; bottomView.requestLayout(); if(value == 100) go2Like(); } }); va.start(); } private void go2Like() { like.setBackgroundResource(R.drawable.likeanim); final AnimationDrawable anim = (AnimationDrawable) like.getBackground(); anim.start(); like.postDelayed(new Runnable() { @Override public void run() { MarginLayoutParams lp = (MarginLayoutParams) bottomView.getLayoutParams(); lp.bottomMargin = 0; bottomView.requestLayout(); anim.stop(); } },650); }}
在动画结束后,播放帧动画让笑脸笑起来,然后把底部view下边距设置回0,就ok了
shape文件
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="@color/colorAccent"/> <corners android:radius="20dp"/></shape>
帧动画的图片可以找类似的就行 主要为了达到效果
阅读全文
1 0
- 实现炫酷的点赞动画
- android实现点赞动画
- 直播点赞动画实现
- 一个优美炫酷的点赞动画
- 图片帧实现Twitter上的点赞动画
- iOS直播APP-点赞动画的实现
- 一分钟实现仿美拍直播的点赞动画
- jQuery点赞动画效果+1的代码实现
- iOS动画系列之九:实现点赞的动画及播放起伏指示器
- 点赞动画的效果
- 点赞动画在listview里面实现
- 高级UI特效仿直播点赞效果—一个优美炫酷的点赞动画
- 类似QQ点赞的动画效果
- iOS一个简单的点赞动画
- 带动画特效的点赞+1
- ShineButton动画点赞的封装
- iOS 使用核心动画加粒子发射器实现的点赞按钮
- 实现锚点的带动画效果(不是突然跳转)
- HDU 3549 适合网络流入门(内含sap模板和Dinic模板)Flow Problem
- webpack代码分离 ensure
- 亲测Activity生命周期及2个Activity 之间切换触发的的方法时间点
- 关于乐鑫,安信可固件使用问题,说明汇总
- 将git默认的编辑器由nano改为vim
- 实现炫酷的点赞动画
- Mock API
- 零基础入门深度学习(2)
- java 多线程随笔( 一)
- isEmpty和isBlank区别
- 对于ObjectAnimator的简单实用
- jquery $(document).ready() 与window.onload的区别
- python3 遍历删除特定后缀名文件
- dataserver 1 FAIL to up ... CHECK IT