[Android] exercise style theme custom activity switching animation, androidactivity

Source: Internet
Author: User

[Android] exercise style theme custom activity switching animation, androidactivity

I have practiced custom styles and themes, inherited and modified the default styles of the android system, and practiced the xml definition of Fade-in and fade-out animations.

Anim/fade_in.xml

<?xml version="1.0" encoding="utf-8"?><alpha xmlns:android="http://schemas.android.com/apk/res/android"    android:duration="3000"    android:fromAlpha="0.0"    android:toAlpha="1.0" />

Anim/fade_out.xml

<?xml version="1.0" encoding="utf-8"?><alpha xmlns:android="http://schemas.android.com/apk/res/android"    android:fromAlpha="1.0"     android:toAlpha="0.0"    android:duration="3000"/>

Values/styles. xml

<? Xml version = "1.0" encoding = "UTF-8"?> <Resources xmlns: android = "http://schemas.android.com/apk/res/android"> <! -- Customize the Animation style --> <style name = 'fade 'parent = "@ android: style/Animation. activity "> <item name =" android: activityOpenEnterAnimation "> @ anim/fade_in </item> <item name =" android: activityOpenExitAnimation "> @ anim/fade_out </item> <item name =" android: activityCloseEnterAnimation "> @ anim/fade_in </item> <item name =" android: activityCloseExitAnimation "> @ anim/fade_out </item> </style> <! -- Custom Animation topic --> <style name = "Theme. tsh "parent =" @ android: style/Theme. light. noTitleBar "> <item name =" android: windowAnimationStyle "> @ style/fade </item> </style> </resources>

MainActivity. java

package com.example.tsh;import android.app.Activity;import android.content.Intent;import android.os.Bundle;import android.os.Handler;public class MainActivity extends Activity {    private Handler handler=new Handler();    @Override    protected void onCreate(Bundle savedInstanceState) {        // TODO Auto-generated method stub        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);        handler.postDelayed(new Runnable() {            @Override            public void run() {                Intent intent=new Intent(MainActivity.this, TwoActivity.class);                startActivity(intent);            }        }, 3000);    }}

Manifest. xml

<? Xml version = "1.0" encoding = "UTF-8"?> <Manifest xmlns: android = "http://schemas.android.com/apk/res/android" package = "com. example. tsh "android: versionCode =" 1 "android: versionName =" 1.0 "> <uses-sdk android: minSdkVersion =" 8 "android: targetSdkVersion = "21"/> <application android: allowBackup = "true" android: icon = "@ drawable/ic_launcher" android: label = "ss"> <activity android: name = ". mainActivity "android: label =" Homepage "android: theme =" @ style/Theme. tsh "> <intent-filter> <action android: name =" android. intent. action. MAIN "/> <category android: name =" android. intent. category. LAUNCHER "/> </intent-filter> </activity> <activity android: name = ". twoActivity "android: theme =" @ style/Theme. tsh "> </activity> </application> </manifest>

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.