Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create animated background gradient like Instagram app?

Below are screenshots of instagram app. The background keeps on transforming from one gradient to other very beautifully. Instagram background gradient

Instagram background gradient

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

like image 492
Bugdroid Avatar asked Feb 16 '16 17:02

Bugdroid


People also ask

How do you animate a gradient in flutter?

To auto animate the gradient just add this block of code in @override Widget build(BuildContext context) {} method of SeriForte's code.


1 Answers

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);
like image 53
Farhad Faghihi Avatar answered Sep 18 '22 08:09

Farhad Faghihi