I am trying to implement Activity Transitions but I am not able to see the effects. Here is the code for my first activity:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_architecture);
setUpWindowAnimations();
}
private void setUpWindowAnimations() {
if (android.os.Build.VERSION.SDK_INT >= 21) {
Log.i("ANIM", "Fade called");
Fade fade = new Fade(2);
fade.setDuration(3000);
getWindow().setExitTransition(fade);
}
}
Here is the code for second activity:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_image);
setUpWindowAnimations();
}
private void setUpWindowAnimations() {
if (android.os.Build.VERSION.SDK_INT >= 21) {
Log.i("ANIM", "slide called");
Slide slide = new Slide(Gravity.LEFT);
slide.setDuration(3000);
getWindow().setEnterTransition(slide);
}
}
Even though I have set Fade out animation, there is no fading, also, Slide works in default way, i.e. the direction is BOTTOM instead of LEFT.
Here is my values/style.xml
and here is my v21/styles.xml
.
Here is my AndroidManifest.xml
:
<application
android:name=".MyApplication"
android:allowBackup="true"
android:hardwareAccelerated="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:largeHeap="true"
android:theme="@style/AppTheme">
Why are these transitions not working and how to make them work. I used paste.ubuntu.com because the SO editor was not showing xml properly.
styles.xml
with your custom transition? – Smellstyles.xml
, I have put a link. – Transubstantiate