Skip to content

Instantly share code, notes, and snippets.

@arianimartins
Created April 30, 2014 19:21
Show Gist options
  • Save arianimartins/de78dbf214341ba4e31d to your computer and use it in GitHub Desktop.
Save arianimartins/de78dbf214341ba4e31d to your computer and use it in GitHub Desktop.
Efeito Fade-in e Fade-out na transição de telas ou fragments
//Em Activity
Intent i = new Intent(MainActivity.this, Destino.java);
startActivity(i);
overridePendingTransition(R.anim.fadein, R.anim.fadeout);
// Em fragments (provavelmente já possúi um código parecido com este)
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction transaction = fragmentManager.beginTransaction();
transaction.setCustomAnimations(R.anim.fadein, R.anim.fadeout); //animação aqui
transaction.commit();
<?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="500" />
<?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="500" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment