【问题标题】:How to animate a radial gradient with a zoom-in animation?如何使用放大动画制作径向渐变动画?
【发布时间】:2019-10-09 19:23:49
【问题描述】:

我想制作一个渐变动画来显示这种背景样式:

  • This 在 0:36-0:41 分钟。

  • 或者在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>

颜色或宽度和高度对我来说并不重要,我需要这个动画,我想知道怎么做,这样我就可以根据我想要的多种颜色或情况来做。

【问题讨论】:

    标签: android animation zooming gradient radial-gradients


    【解决方案1】:

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

    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 类中:

    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 来启动和停止动画

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-12-16
      • 2019-12-04
      • 2014-07-06
      • 2014-11-28
      • 1970-01-01
      相关资源
      最近更新 更多