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?
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.
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.
An Android Splash Screen is the first screen that is visible to the user when the app is launched.
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.
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.
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