Reputation: 6188
I have an Android app in which nine of the activities do not load a layout file. Their views are private classes which extend the View class. The activity construct view objects at runtime and uses these objects instead of layout files. The problem that I have is that the views created these activities should slide in and slide out both left and right when switching to other views. I have used a ViewFlipper before but I am unable to one with my need here since view flippers take layout files rather than activities. Is there any chance my problem can be solved without resolving to switching to layout files?
Upvotes: 3
Views: 12437
Reputation: 6475
Try thoses
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<translate
android:duration="@android:integer/config_longAnimTime"
android:fromXDelta="0"
android:fromYDelta="0"
android:interpolator="@android:anim/linear_interpolator"
android:toXDelta="-100%"
android:toYDelta="0" />
</set>
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<translate
android:duration="@android:integer/config_longAnimTime"
android:fromXDelta="100%"
android:fromYDelta="0"
android:interpolator="@android:anim/linear_interpolator"
android:toXDelta="0"
android:toYDelta="0" />
</set>
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<translate
android:duration="@android:integer/config_longAnimTime"
android:fromXDelta="-100%"
android:fromYDelta="0"
android:interpolator="@android:anim/linear_interpolator"
android:toXDelta="0"
android:toYDelta="0" />
</set>
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<translate
android:duration="@android:integer/config_longAnimTime"
android:fromXDelta="0"
android:fromYDelta="0"
android:interpolator="@android:anim/linear_interpolator"
android:toXDelta="100%"
android:toYDelta="0" />
</set>
And in the code when doing StartActivity()
overridePendingTransition(R.animator.anim_left, R.animator.anim_right);
and then when doing finish()
overridePendingTransition(R.animator.anim_left, R.animator.anim_right);
Upvotes: 8
Reputation: 17580
this.overridePendingTransition(android.R.anim.slide_in_left,
android.R.anim.slide_out_right);
write it just below of your Intent.
Upvotes: 7