android 仿蘑菇街喜欢
来源:互联网 发布:软件开发逻辑架构 编辑:程序博客网 时间:2024/04/28 16:00
采用三个view设置动画 感觉有点麻烦 ..不知谁有更好的解决布局文件 :<pre name="code" class="html"><FrameLayout android:layout_width="match_parent" android:layout_height="match_parent"> <RelativeLayout android:id="@+id/layout_mgj_like" android:layout_width="match_parent" android:layout_height="match_parent"> <ImageView android:id="@+id/iv_mgj_like_i" android:layout_width="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:visibility="gone" android:layout_height="wrap_content"/> <ImageView android:id="@+id/iv_mgj_like_ii" android:layout_width="wrap_content" android:layout_height="wrap_content" android:visibility="gone" android:layout_centerHorizontal="true" android:layout_centerVertical="true"/> <ImageView android:id="@+id/iv_mgj_like_iii" android:background="@drawable/mgj_unlike" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" /> </RelativeLayout> <RelativeLayout android:id="@+id/layout_mgj_unlike" android:visibility="gone" android:layout_width="match_parent" android:layout_height="match_parent"> <ImageView android:id="@+id/iv_mgj_unlike_left" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignTop="@+id/iv_mgj_unlike_right" android:layout_centerHorizontal="true" /> <ImageView android:id="@+id/iv_mgj_unlike_right" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_toRightOf="@+id/iv_mgj_unlike_left"/> </RelativeLayout> </FrameLayout>
<pre style="background-color:#2b2b2b;color:#a9b7c6;font-family:'Source Code Pro';font-size:12.0pt;">
application代码:
<pre name="code" class="java">//仿蘑菇街 喜欢 final RelativeLayout layoutMgjLike = (RelativeLayout) findViewById(R.id.layout_mgj_like); final ImageView ivMgjlikei = (ImageView) findViewById(R.id.iv_mgj_like_i); final ImageView ivMgjlikeii = (ImageView) findViewById(R.id.iv_mgj_like_ii); final ImageView ivMgjlikeiii = (ImageView) findViewById(R.id.iv_mgj_like_iii); final RelativeLayout layoutMgjUnlike = (RelativeLayout) findViewById(R.id.layout_mgj_unlike); final ImageView ivMgjUnlikeLeft = (ImageView) findViewById(R.id.iv_mgj_unlike_left); final ImageView ivMgjUnlikeRight = (ImageView) findViewById(R.id.iv_mgj_unlike_right); layoutMgjLike.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { ivMgjlikei.setBackgroundResource(R.drawable.mgj_like); ivMgjlikeii.setBackgroundResource(R.drawable.mgj_like); ivMgjlikeiii.setBackgroundResource(R.drawable.mgj_like); ivMgjlikeii.setVisibility(View.VISIBLE); ivMgjlikei.setVisibility(View.VISIBLE); AnimatorSet setLike = new AnimatorSet(); ObjectAnimator animIScaleX = ObjectAnimator.ofFloat(ivMgjlikei, "scaleX", 0.0f, 4.0f); ObjectAnimator animIScaleY = ObjectAnimator.ofFloat(ivMgjlikei, "scaleY", 0.0f, 4.0f); ObjectAnimator animIAlpha = ObjectAnimator.ofFloat(ivMgjlikei, "alpha", 1.0f, 0.0f); ObjectAnimator animIIScaleX = ObjectAnimator.ofFloat(ivMgjlikeii, "scaleX", 0.0f, 2.5f); ObjectAnimator animIIScaleY = ObjectAnimator.ofFloat(ivMgjlikeii, "scaleY", 0.0f, 2.5f); ObjectAnimator animIIAlpha = ObjectAnimator.ofFloat(ivMgjlikeii, "alpha", 1.0f, 0.5f); ObjectAnimator animIIIScaleX = ObjectAnimator.ofFloat(ivMgjlikeiii, "scaleX", 0.0f, 1.5f); ObjectAnimator animIIIScaleY = ObjectAnimator.ofFloat(ivMgjlikeiii, "scaleY", 0.0f, 1.5f); ObjectAnimator animIIIAlpha = ObjectAnimator.ofFloat(ivMgjlikeiii, "alpha", 1.0f, 0.8f); setLike.play(animIScaleX).with(animIScaleY).with(animIAlpha) .with(animIIScaleX).with(animIIScaleY).with(animIIAlpha) .with(animIIIScaleX).with(animIIIScaleY).with(animIIIAlpha); setLike.setDuration(500).start(); setLike.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); AnimatorSet setlikeEnd = new AnimatorSet(); ObjectAnimator animIIISmallScaleX = ObjectAnimator.ofFloat(ivMgjlikeiii, "scaleX", 1.5f, 1.0f); ObjectAnimator animIIISmallScaleY = ObjectAnimator.ofFloat(ivMgjlikeiii, "scaleY", 1.5f, 1.0f); ObjectAnimator animIIITohighAlpha = ObjectAnimator.ofFloat(ivMgjlikeiii, "alpha", 0.8f, 1.0f); setlikeEnd.play(animIIITohighAlpha).with(animIIISmallScaleX).with(animIIISmallScaleY); setlikeEnd.setDuration(200).start(); ivMgjlikeii.setVisibility(View.GONE); ivMgjlikei.setVisibility(View.GONE); layoutMgjUnlike.setVisibility(View.VISIBLE); } }); } }); layoutMgjUnlike.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { layoutMgjLike.setVisibility(View.GONE); ivMgjUnlikeLeft.setBackgroundResource(R.drawable.mgj_unlike_left); ivMgjUnlikeRight.setBackgroundResource(R.drawable.mgj_unlike_right); AnimatorSet setUnlike = new AnimatorSet(); ObjectAnimator animTranslationY = ObjectAnimator.ofFloat(ivMgjUnlikeLeft, "translationY", 0.0f, 60f); ObjectAnimator animTranslationX = ObjectAnimator.ofFloat(ivMgjUnlikeLeft, "translationX", 0.0f, -60f); ObjectAnimator animRotate = ObjectAnimator.ofFloat(ivMgjUnlikeLeft, "rotation", 0, -60); ObjectAnimator animAlpha = ObjectAnimator.ofFloat(ivMgjUnlikeLeft, "alpha", 1.0f, 0.0f); ObjectAnimator animRightTranslationY = ObjectAnimator.ofFloat(ivMgjUnlikeRight, "translationY", 0.0f, 60f); ObjectAnimator animRightTranslationX = ObjectAnimator.ofFloat(ivMgjUnlikeRight, "translationX", 0.0f, 60f); ObjectAnimator animRightRotate = ObjectAnimator.ofFloat(ivMgjUnlikeRight, "rotation", 0, 60); ObjectAnimator animRightAlpha = ObjectAnimator.ofFloat(ivMgjUnlikeRight, "alpha", 1.0f, 0.0f); setUnlike.play(animTranslationY).with(animRotate).with(animTranslationX).with(animAlpha) .with(animRightTranslationY).with(animRightRotate).with(animRightTranslationX).with(animRightAlpha); setUnlike.setDuration(400).start(); setUnlike.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); layoutMgjLike.setVisibility(View.VISIBLE); ivMgjlikeiii.setBackgroundResource(R.drawable.mgj_unlike); layoutMgjUnlike.setVisibility(View.GONE); } }); } });
源码:http://download.csdn.net/detail/u010906557/9223541
0 0
- android 仿蘑菇街喜欢
- android 瀑布流效果(仿蘑菇街)
- android 瀑布流效果(仿蘑菇街)
- android 瀑布流效果(仿蘑菇街)
- android 瀑布流效果(仿蘑菇街)
- android 瀑布流效果(仿蘑菇街)
- android 瀑布流效果(仿蘑菇街)
- android 瀑布流效果(仿蘑菇街) .
- android 瀑布流效果(仿蘑菇街)
- android 瀑布流效果(仿蘑菇街)
- android 瀑布流效果(仿蘑菇街)
- android 瀑布流效果(仿蘑菇街)
- 仿蘑菇街个人主页
- Android UI设计之 仿做蘑菇街UI设计
- android瀑布流效果(仿蘑菇街)
- android瀑布流效果(仿蘑菇街)
- android瀑布流效果(仿蘑菇街)
- Android之---高仿蘑菇街欢迎页面实现
- android五种布局模式
- 【Objective-C Runtime】之理解
- CAS单点登录(SSO)完整教程
- Universal-Image-Loader,android-Volley,Picasso、Fresco和Glide五大Android开源组件加载网络图片的优缺点比较
- textView输入字数统计
- android 仿蘑菇街喜欢
- Linux基础一cd 与 ls 命令详解
- 二维树状数组
- 让微信二维码扫描您的APK
- 实现TextView的倒影效果
- WPF分页控件
- android即时消息处理机制
- 近期面试遇到的问题以及总结(python和openstack)
- Android按比例布局之layout_weight和weightSum的使用