[Android] Practice style theme customizing activity toggle Animation

Source: Internet
Author: User

Practice the custom styles and themes, inherit the default styles and modify the Android system, practice XML definition fade animations

Anim/fade_in.xml

<? XML version= "1.0" encoding= "Utf-8" ?> <  xmlns:android= "http://schemas.android.com/apk/res/android"    android:duration  = "    android:fromalpha" = "0.0"    android:toalpha= "1.0"/>

Anim/fade_out.xml

<? XML version= "1.0" encoding= "Utf-8" ?> <  xmlns:android= "http://schemas.android.com/apk/res/android"    android: Fromalpha= "1.0"     android:toalpha= "0.0"    android:duration  = "/> "

Values/styles.xml

<?XML version= "1.0" encoding= "Utf-8"?><Resourcesxmlns:android= "Http://schemas.android.com/apk/res/android">    <!--Custom Animation Styles -    <stylename= ' fade 'Parent= "@android: style/animation.activity">        <Itemname= "Android:activityopenenteranimation">@anim/fade_in</Item>        <Itemname= "Android:activityopenexitanimation">@anim/fade_out</Item>        <Itemname= "Android:activitycloseenteranimation">@anim/fade_in</Item>        <Itemname= "Android:activitycloseexitanimation">@anim/fade_out</Item>    </style>    <!--Custom Animated Themes -    <stylename= "Theme.tsh"Parent= "@android: Style/theme.light.notitlebar">        <Itemname= "Android:windowanimationstyle">@style/fade</Item>    </style></Resources>

Mainactivity.java

 Packagecom.example.tsh;Importandroid.app.Activity;Importandroid.content.Intent;ImportAndroid.os.Bundle;ImportAndroid.os.Handler; Public classMainactivityextendsActivity {PrivateHandler handler=NewHandler (); @Overrideprotected voidonCreate (Bundle savedinstancestate) {//TODO auto-generated Method Stub        Super. OnCreate (savedinstancestate);        Setcontentview (R.layout.activity_main); Handler.postdelayed (NewRunnable () {@Override Public voidrun () {Intent Intent=NewIntent (mainactivity. This, Twoactivity.class);            StartActivity (Intent); }        }, 3000); }}

Manifest.xml

<?XML version= "1.0" encoding= "Utf-8"?><Manifestxmlns:android= "Http://schemas.android.com/apk/res/android" Package= "Com.example.tsh"Android:versioncode= "1"Android:versionname= "1.0" >    <USES-SDKandroid:minsdkversion= "8"android:targetsdkversion= "+" />    <ApplicationAndroid:allowbackup= "true"Android:icon= "@drawable/ic_launcher"Android:label= "ss" >        <ActivityAndroid:name=". Mainactivity "Android:label= "Home"Android:theme= "@style/theme.tsh" >            <Intent-filter>                <ActionAndroid:name= "Android.intent.action.MAIN" />                <categoryAndroid:name= "Android.intent.category.LAUNCHER" />            </Intent-filter>        </Activity>        <ActivityAndroid:name=". Twoactivity "Android:theme= "@style/theme.tsh" >        </Activity>    </Application></Manifest>

[Android] Practice style theme customizing activity toggle Animation

Related Article

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.