[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>