Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/Taishi-Y/InstagramLikeColorTransitionAndroid

How to create instagram like Gradient color transition in android.📸
https://github.com/Taishi-Y/InstagramLikeColorTransitionAndroid

android animation gradient-color-transition instagram transition

Last synced: 1 day ago
JSON representation

How to create instagram like Gradient color transition in android.📸

Lists

README

        

# InstagramLikeColorTransition

[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-InstagramLikeColorTransition-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/5035)

[中文版](https://github.com/Taishi-Y/InstagramLikeColorTransitionAndroid/blob/master/README_cn.md) by [zhaoweih](https://github.com/zhaoweih)

How to create instagram like Gradient color transition in android.

#### 1. Create some gradient color drawables inside drawable Folder.

color1.xml
```xml

```

color2.xml
```xml

```

color3.xml
```xml

```

color4.xml
```xml

```

#### 2. Create animation list using the above created gradient colors, animation_list.xml, inside drawable folder

```xml




```

#### 3. Apply the animation_list created above as a background to the top view of your activity layout.

```xml

```

#### 4. Inside your activity use AnimationDrawable to apply the transition.
```java
LinearLayout container = (LinearLayout) findViewById(R.id.container);

AnimationDrawable anim = (AnimationDrawable) container.getBackground();
anim.setEnterFadeDuration(6000);
anim.setExitFadeDuration(2000);

// Starting animation:- start the animation on onResume.
@Override
protected void onResume() {
super.onResume();
if (anim != null && !anim.isRunning())
anim.start();
}

// Stopping animation:- stop the animation on onPause.
@Override
protected void onPause() {
super.onPause();
if (anim != null && anim.isRunning())
anim.stop();
}
```

### Make statusbar transparent

values/styles.xml
```xml



```

values-v19/styles.xml
```xml


<item name="android:windowTranslucentStatus">true</item>


```

values-v21/styles.xml
```xml


<item name="android:statusBarColor">@android:color/transparent</item>


```

values-v23/styles.xml
```xml


<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowLightStatusBar">true</item>


```

```java

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

// Add below code
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
findViewById(android.R.id.content).setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
}

setContentView(R.layout.activity_splash);
}
}
```

```xml

```