如何使用放大动画为径向渐变制作动画?

How to animate a radial gradient with a zoom-in animation?

我想制作渐变动画以显示此背景样式:

  • This at minute 0:36-0:41.

  • Or in This article(the animation, not plain image).

  • Or Something like this:

我需要适合加载屏幕和背景中的自定义对话框动画。

现在我想要这个的原因是向我的用户显示一个新生成的密码(生成和创建密码的过程,而不是显示生成的结果密码)。

我已经搜索了很多网站和 YouTube 链接,其中大部分都没有使用 java 或者只是解释如何制作径向渐变,就像我在没有动画的普通屏幕上所做的那样欲望.

我有以下梯度:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <gradient
        android:type="radial"
        android:gradientRadius="100%p"
        android:startColor="#F1F1F1"
        android:endColor="#83a6aa" />
</shape>

颜色或宽度和高度对我来说无关紧要,我需要这个动画,我想知道怎么做,这样我就可以为我想要的颜色或情况做任何事情。

我找到的最接近的解决方案:

Github Library

-- 布局:

<com.skyfishjy.library.RippleBackground
        android:id="@+id/ripple_content"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:rb_color="#20000000"
        app:rb_duration="3000"
        app:rb_radius="22dp"
        app:rb_rippleAmount="12"
        app:rb_scale="22"
        app:rb_type="strokeRipple"
        app:rb_strokeWidth="1dp">

        <!-- like any layout, insert items here like a normal layout-->

</com.skyfishjy.library.RippleBackground>

在您使用此布局的 java class 中:

final RippleBackground rippleBackground=(RippleBackground)findViewById(R.id.content);
// override the methods: onStart, onResume and insert to them the next line
rippleBackground.startRippleAnimation();
// if you wish to stop the animation use:
rippleBackground.stopRippleAnimation();

请注意,您也可以通过单击任何类型的 onClickListener

来启动和停止动画