Reputation: 4535
I am trying to implement slide animation to left and right which I was unable to complete. I have some sample code like follows,
overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
When I try this in 4.2 it is showing an error like and suggesting me to "Create a field 'anim' in type 'R'" or "Create constant 'anim' in type 'R'" . Can anyone suggest me how can I overcome this problem? if any code is there to implement that will be really great.
Thanks, Chandra.
Upvotes: 0
Views: 2783
Reputation: 431
anim is animation folder in res dir. slide_in_right is the xml file which needs to be created and animation information provided there.
so you need to provide both animation information in slide_in_right.xml and slide_out_left.xml files in anim folder in res dir.
Code in slide_out_left.xml can be like:
<?xml version="1.0" encoding="UTF-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromXDelta="-100%p" android:toXDelta="0%p" android:duration="300" />
</set>
and for slide_in_right.xml
<?xml version="1.0" encoding="UTF-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromXDelta="0%p" android:toXDelta="100%p" android:duration="300" />
</set>
put these file in anim folder in res dir and it should work.
Upvotes: 1