问题描述
下面是Instagram的应用程序的屏幕截图。背景不断变换从一个梯度对方很漂亮。
Below are screenshots of instagram app. The background keeps on transforming from one gradient to other very beautifully.
我想知道我怎么能做到这一点。有没有code到动画一个梯度自动还是我需要添加不同梯度,只是稍有不同,如果我用它不会造成Instagram的任何版权问题?我曾尝试使用动画渐变的多个文件,只是稍有不同使用帧动画,但它不顺利和不顺利。谢谢
I want to know how can I achieve this. IS THERE ANY CODE TO ANIMATE A GRADIENT AUTOMATICALLY OR DO I NEED TO ADD DIFFERENT GRADIENTS WITH SLIGHT VARIATION, and if I use it won't cause any copyright issues with Instagram? I have tried animating using multiple gradient files with slight variation using Frame Animation but it isn't smooth and doesn't work well. Thanks
推荐答案
创建TransitionDrawable到您使用的背景的两种可绘之间切换。
Create a TransitionDrawable to change between two drawables that you use for the background.
<?xml version="1.0" encoding="UTF-8"?>
<transition xmlns:android="http://schemas.android.com/apk/res/android">
<!-- use whatever drawables you want, gradients, shapes etc-->
<item android:drawable="@drawable/start" />
<item android:drawable="@drawable/end" />
</transition>
TransitionDrawable trans = (TransitionDrawable) myLayout.getBackground();
trans.startTransition(2000);
这篇关于如何创建动画背景渐变像Instagram的应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!