博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
揭露动画(Reveal Effect)实现时的注意事项(附上bug-logcat) ...
阅读量:5889 次
发布时间:2019-06-19

本文共 3900 字,大约阅读时间需要 13 分钟。

Debug完成图:

img_e7c47f3bff9d777d96c725316bea4902.gif
Debug完成图

昨天晚上开始学一下这个揭露动画,准备用在项目中做一个转场,啃完了API之后开始写个小demo,距离跑成功一步之遥的当儿,出了个bug,就怎么点击按钮都没用。

首先上bug图:

img_7137b4e15d552b3619f132ef1f144063.png

bug:怎么点击按钮都没用,每点击一次都会出现下面的报错(2040):

11-07 19:20:49.665 2454-2454/? I/Finsky: [1] com.google.android.finsky.services.j.a(149): Installation state replication succeeded.11-07 19:20:49.711 7448-7448/? E/hei: 204011-07 19:20:49.718 1350-1371/? W/audio_hw_generic: Not supplying enough data to HAL, expected position 5613338 , only wrote 561312011-07 19:20:50.376 7448-7448/? E/hei: 204011-07 19:20:50.992 7448-7448/? E/hei: 204011-07 19:20:51.591 7448-7448/? E/hei: 204011-07 19:20:54.790 1350-1372/? W/audio_hw_generic: Not supplying enough data to HAL, expected position 6098164 , only wrote 585648011-07 19:20:58.322 7448-7448/? E/hei: 204011-07 19:20:58.328 1350-1371/? W/audio_hw_generic: Not supplying enough data to HAL, expected position 5856667 , only wrote 585648011-07 19:21:01.540 1350-1372/? W/audio_hw_generic: Not supplying enough data to HAL, expected position 6162708 , only wrote 6010560

activity.java全文:

package com.lwp.justtest;import android.animation.Animator;import android.animation.AnimatorListenerAdapter;import android.support.design.widget.FloatingActionButton;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.util.Log;import android.view.View;import android.view.ViewAnimationUtils;public class MainActivity extends AppCompatActivity implements View.OnClickListener {    boolean flag = false;    FloatingActionButton fab;    private View mPuppet;    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);        mPuppet = findViewById(R.id.view_puppet);        fab = (FloatingActionButton)findViewById(R.id.fab);        fab.setOnClickListener(this);    }    @Override    public void onClick(View v) {        doRevealAnimation();    }    private void doRevealAnimation() {        int[] vLocation = new int[2];        fab.getLocationInWindow(vLocation);        int centerX = vLocation[0] + fab.getMeasuredWidth() / 2;        int centerY = vLocation[1] + fab.getMeasuredHeight() / 2;        int height = mPuppet.getHeight();        int width = mPuppet.getWidth();        int maxRradius = (int) Math.hypot(height, width);        Log.e("hei", maxRradius + "");        if (flag) {            Animator animator = ViewAnimationUtils.createCircularReveal(mPuppet, centerX, centerY, maxRradius, 0);            animator.setDuration(1000);            animator.addListener(new AnimatorListenerAdapter() {                @Override                public void onAnimationEnd(Animator animation) {                    super.onAnimationEnd(animation);                    mPuppet.setVisibility(View.GONE);                }            });            animator.start();            flag = false;        } else {            Animator animator = ViewAnimationUtils.createCircularReveal(mPuppet, centerX, centerY, 0, maxRradius);            animator.setDuration(1000);            animator.addListener(new Animator.AnimatorListener() {                @Override                public void onAnimationStart(Animator animation) {                    mPuppet.setVisibility(View.VISIBLE);                }                @Override                public void onAnimationEnd(Animator animation) {                }                @Override                public void onAnimationCancel(Animator animation) {                }                @Override                public void onAnimationRepeat(Animator animation) {                }            });            animator.start();            flag = true;        }    }}

layout.xml全文:

观众朋友们,这个看出毛病了吗。

我想了一下,额,会不会我的View没有设置颜色啊。。好的试了一下,果然是,可以说是很鬼畜了。。

layout.xml里边的View控件改成下面这样子,再次运行程序就成了(发现2040还是会报错,但是动画算是完美跑出来了,所以小伙伴们这里记得设置android:background以及android:visibility噢):

效果图如下:

img_e7c47f3bff9d777d96c725316bea4902.gif

转载地址:http://crgix.baihongyu.com/

你可能感兴趣的文章
一致哈希
查看>>
The connection to adb is down, and a severe error has occured. 问题解决
查看>>
在Jenkins中配置运行远程shell命令
查看>>
代码杂记
查看>>
linux中防CC攻击两种实现方法(转)
查看>>
《Programming WPF》翻译 第9章 4.模板
查看>>
Windows7+VS2012下OpenGL 4的环境配置
查看>>
Linux Kernel中断子系统来龙去脉浅析【转】
查看>>
Linux NFS服务器的安装与配置
查看>>
Ada boost学习
查看>>
Unity中SendMessage和Delegate效率比较
查看>>
Linux下EPoll通信模型简析
查看>>
react-native 制作购物车ShopCart
查看>>
Linux服务器 java生成的图片验证码乱码问题
查看>>
【转】QT中QDataStream中浮点数输出问题
查看>>
mongodb3.2配置文件yaml格式 详解
查看>>
centOS_5.4_安装Open×××
查看>>
Spring Security OAuth2 开发指南
查看>>
TCP
查看>>
参观迅达云成公司有感
查看>>