Home > Web Front-end > HTML Tutorial > Android page switching animation code implementation_html/css_WEB-ITnose

Android page switching animation code implementation_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:47:08
Original
1228 people have browsed it

1. Create a new anim package under project Src

Create anim package to store animation xml

2. Next step animation position animation

Explanation - 100% p p: represents Parent form, 100%: represents the entire form, -: the code moves to the left;
Move out the previous page: tran_out.xml (if you create it yourself, select translate)
<?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:fromYDelta="0"    android:toYDelta="0"    android:duration="500"    >    </translate>
Copy after login
Enter the next page: Tran_in .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"    android:fromYDelta="0"    android:toYDelta="0"    android:duration="500"    ></translate>
Copy after login

3. Use animation:

Add in the method body executed under button onclike: overridePendingTransition(R.anim.tran_in, R.anim.tran_out);
//Two An activity switching effect can be placed after finish() or startActivity()

Similarly, attach the previous animation code
Tran_pre_out.xm;
<?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:fromYDelta="0"    android:toYDelta="0"    android:duration="500"    ></translate>
Copy after login
Tran_pre_in.xm
<?xml version="1.0" encoding="utf-8"?><translate  xmlns:android="http://schemas.android.com/apk/res/android"    android:fromXDelta="-100%p"    android:toXDelta="0"    android:fromYDelta="0"    android:toYDelta="0"    android:duration="500"    ></translate>
Copy after login
Use animation:
overridePendingTransition(R.anim.tran_pre_in, R.anim.tran_pre_out);

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template