• Stars
    star
    601
  • Rank 74,537 (Top 2 %)
  • Language
    Java
  • License
    MIT License
  • Created almost 8 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

How to create instagram like Gradient color transition in android.๐Ÿ“ธ

InstagramLikeColorTransition

Android Arsenal

ไธญๆ–‡็‰ˆ by zhaoweih

How to create instagram like Gradient color transition in android.

1. Create some gradient color drawables inside drawable Folder.

color1.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <gradient
        android:startColor="#614385"
        android:endColor="#516395"
        android:angle="0"/>
</shape>

color2.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <gradient
        android:startColor="#5f2c82"
        android:endColor="#49a09d"
        android:angle="45"/>
</shape>

color3.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <gradient
        android:startColor="#4776E6"
        android:endColor="#8E54E9"
        android:angle="90"/>
</shape>

color4.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <gradient
        android:startColor="#7141e2"
        android:endColor="#d46cb3"
        android:angle="135"/>
</shape>

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

<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:drawable="@drawable/color1"
        android:duration="10000" />
    <item
        android:drawable="@drawable/color2"
        android:duration="10000" />
    <item
        android:drawable="@drawable/color3"
        android:duration="10000" />
    <item
        android:drawable="@drawable/color4"
        android:duration="10000" />
</animation-list>

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

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@drawable/animation_list"
    android:id="@+id/container">

    <!-- Child Views -->

</LinearLayout>

4. Inside your activity use AnimationDrawable to apply the transition.

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

<resources>  
    <style name="Theme.AppTheme.TranslucentStatusBar" parent="Theme.AppCompat.Light.NoActionBar" />  
</resources>  

values-v19/styles.xml

<resources>  
    <style name="Theme.AppTheme.TranslucentStatusBar" parent="Theme.AppCompat.Light.NoActionBar">  
        <item name="android:windowTranslucentStatus">true</item>  
    </style>  
</resources> 

values-v21/styles.xml

<resources>  
    <style name="Theme.AppTheme.TranslucentStatusBar" parent="Theme.AppCompat.Light.NoActionBar">  
        <item name="android:statusBarColor">@android:color/transparent</item>  
    </style>  
</resources>  

values-v23/styles.xml

<resources>  
    <style name="Theme.AppTheme.TranslucentStatusBar" parent="Theme.AppCompat.Light.NoActionBar">  
        <item name="android:statusBarColor">@android:color/transparent</item>  
        <item name="android:windowLightStatusBar">true</item>  
    </style>  
</resources> 
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);  
    }  
}  
<activity  
    android:name=".MainActivity"  
    android:theme="@style/Theme.AppTheme.TranslucentStatusBar" /> 

More Repositories

1

MusicIndicator

Music indicator for Android. Easy to use. ๐ŸŽง โœจ
Java
493
star
2

FlipProgressDialog

Airbnb like ProgressDialog with Image Flip Animation.๐Ÿ›Œ๐Ÿžโœจ
Java
104
star
3

KArchi

Repository that showcases 3 different Android app architectures, all with Java and Kotlin versions: "Standard Android", MVP and MVVM. The exact same app is built 6 times following the different patterns.
Java
21
star
4

walker

Swipe card UI (like a Tinder) with FourSqure API, facebook login, Firebase.
Java
12
star
5

Scribd

Book Finder with Google Book API
Java
6
star
6

SpeechBookBrowser

Automatically continue speeching HTML elements by using Text to Speech in Android webview
HTML
6
star
7

Android_Projects_by_TaishiYamasaki

Android sample projects and a bunch of code snippets by Taishi Yamasaki
Java
4
star
8

FourSquareAPIwithMVP

MVP pattern with Foursquare API. Model View Presenter.
Java
2
star
9

Foursquare-API-client-sample-app-for-Android

This project is getting venue datas from Foursquare API.( https://developer.foursquare.com/overview/ )
Java
2
star
10

CollapsingToolbarLayoutSample

This is the simplest and common usage of CollapsingToolbarLayout.๐Ÿ™Œ
Java
2
star
11

JapaneseRemoteWorkers

ไธปใซๆตทๅค–ใงใƒชใƒขใƒผใƒˆใƒฏใƒผใ‚ฏใ—ใฆใ„ใ‚‹ๆ—ฅๆœฌไบบใฎๆ–นใ‚’ใพใจใ‚ใพใ—ใŸ๐Ÿ‡ฏ๐Ÿ‡ต ใฟใชใ•ใ‚“็Ÿฅ่ฆ‹ใฎๅกŠใฟใŸใ„ใชๆ–นใฐใ‹ใ‚Šใงใ™ใฎใงใ€ๆƒ…ๅ ฑไบคๆ›ใฎๅŠฉใ‘ใซใชใ‚Œใฐใ„ใ„ใชใจๆ€ใ„ใพใ™๐Ÿ™‡โ€โ™‚๏ธ
1
star
12

rememberry-prototype

The POC of Rememberry extension
JavaScript
1
star