Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Want to animate splash screen on Android

I want to add fade in and fade out to a splash screen after a few seconds of loading. Is there a sample for doing this to my splash layout?

like image 475
cavallo Avatar asked Nov 25 '11 10:11

cavallo


People also ask

How do I make a splash screen app for Android?

The most straightforward way to create a simple splash screen was to create a dedicated theme overriding android:windowBackground with a drawable containing branding colors or a bitmap of a logo. The theme was set as an attribute of the launcher activity in AndroidManifest. xml.

Can you animate on Android?

With over a million downloads, Animation Desk is one of the best animation apps for Android that you can try. It has all the things that make an animation app great—a clutter-free user interface, an adequate amount of options, and a handful of ways to export the finished animation.

What is a splash screen animation?

An Android Splash Screen is the first screen that is visible to the user when the app is launched.


2 Answers

This is an example of slow transition between activities. You can add your own animation:

public class OneActivity extends Activity
{
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.one);
        ((Button)findViewById(R.id.next_button)).setOnClickListener(new OnClickListener()
        {
            @Override
            public void onClick(View v)
            {
                startActivity(new Intent(OneActivity.this, TwoActivity.class));
                overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_left);
            }
        });
    }
}

slide_in_left.xml:

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromXDelta="100%p" android:toXDelta="0%p"
    android:duration="@android:integer/config_longAnimTime"/>

slide_out_left.xml:

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromXDelta="0" android:toXDelta="-100%p"
    android:duration="@android:integer/config_longAnimTime" />

Fade in and fade out effects:

<!-- Fade out -->
<?xml version="1.0" encoding="UTF-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator"
android:fromAlpha="1.0" android:toAlpha="0.0"
android:duration="300" />

<!-- Fade in -->
<?xml version="1.0" encoding="utf-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator"
android:fromAlpha="0.0" android:toAlpha="1.0"
android:duration="300" />

<!-- Slide in right and slide out right  -->
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromXDelta="-100%p" android:toXDelta="0%p"
    android:duration="@android:integer/config_longAnimTime" />

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromXDelta="0" android:toXDelta="100%p"
    android:duration="@android:integer/config_longAnimTime" />

Also take a look on Splash Fade, Activity Animations, overridePendingTransition.

like image 136
Ramesh Akula Avatar answered Oct 11 '22 03:10

Ramesh Akula


Yes, you can add an animation to an activity, a view and so on...

Check the post Animation Resources to get the idea to apply animation.

like image 23
Last Warrior Avatar answered Oct 11 '22 04:10

Last Warrior