Home > Web Front-end > HTML Tutorial > activity switching animation and page switching animation_html/css_WEB-ITnose

activity switching animation and page switching animation_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 12:04:34
Original
1267 people have browsed it

Activity switching animation

To achieve Activity switching animation, you need to rely on overridePendingTransition. There are two parameters in it: the animation when entering the Activity and the animation when leaving the Activity.

It should be noted that it must be called immediately after StartActivity() or finish()

For example, if there is a Button in MainActivity, the code to jump to OtherActivity after clicking the Button is as follows:

		Intent intent = new Intent(this, OtherActivity.class);		startActivity(intent);		this.overridePendingTransition(R.anim.enteralpha, R.anim.exitalpha);
Copy after login

Interface switching animation

Interface switching animation relies on ViewFlipper to implement

    <ViewFlipper        android:id="@+id/view_flipper"        android:layout_width="match_parent"        android:layout_height="match_parent" >        <!-- 第一页 -->        <LinearLayout            android:layout_width="match_parent"            android:layout_height="match_parent"            android:background="#009900"            android:orientation="vertical" >            <TextView                android:layout_width="match_parent"                android:layout_height="wrap_content"                android:text="第一页" />        </LinearLayout>        <!-- 第二页 -->        <LinearLayout            android:layout_width="match_parent"            android:layout_height="match_parent"            android:background="#ffff00"            android:orientation="vertical" >            <TextView                android:layout_width="match_parent"                android:layout_height="wrap_content"                android:text="第二页" />        </LinearLayout>    </ViewFlipper>
Copy after login

Then determine the finger Is it sliding left or right?

	@Override	public boolean onTouchEvent(MotionEvent event) {		// TODO Auto-generated method stub		if (event.getAction() == MotionEvent.ACTION_DOWN) {			startX = event.getX();		} else if (event.getAction() == MotionEvent.ACTION_UP) {			float endX = event.getX();			if (endX > startX ) {				flipper.showNext();// 显示下一页			} else if (endX<startX) {				flipper.showPrevious();// 显示前一页			}			return true;		}		return super.onTouchEvent(event);	}
Copy after login

This way you can switch pages when sliding your finger left or right.


Related labels:
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