Below are screenshots of instagram app. The background keeps on transforming from one gradient to other very beautifully.
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
To auto animate the gradient just add this block of code in @override Widget build(BuildContext context) {} method of SeriForte's code.
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>
Transition Drawables in Android
TransitionDrawable trans = (TransitionDrawable) myLayout.getBackground();
trans.startTransition(2000);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With