Activity cancels the default animation method for interface switching (recommended) _android

Source: Internet
Author: User

Generally starting a new activity has a toggle animation effect by default, such as moving the interface from right to left.

But sometimes we do not need this animation, how to do?

Operation method is more troublesome, here I recommend one of them. I'm here to do the boot page splash to home seamless display, that is, the start page of the picture background and the top of the top-level suspension background image is exactly the same, the user will think that the launch page, I will do some animation, and then open the door effect. (The home page will be 2 more buttons, this time is not the startup pages)

Main ways to achieve:

1, need to set the theme of no animation effect, apply to the corresponding interface.

2, in the Start Page interface end, need to add a method overridependingtransition (0, 0);

Before the SplashActivity.this.finish ();

3, GIF in the Start Page and homepage are the same picture (home layout above the suspension of the start page of the picture, using window Decorview)

4, in Style.xml, you need to add the following topic, where parent= "Apptheme" in the parent theme is you apply your own theme, name= "Theme" Theme is about to be used. Next on the home page of the android:theme= "@style/theme" set to your homepage (that is, you start page jump next page).

<!--Cancel interface Transitions animation using--> <style name= "Theme" parent= "Apptheme" > <item name= "Android:windowanimationstyle" & gt; @style/animation</item> </style> <style name= "Animation" > <item name= "Android:activityopen" Enteranimation "> @null </item> <item name=" android:activityopenexitanimation "> @null </item> Item Name= "Android:activitycloseenteranimation" > @null </item> <item name= "Android: Activitycloseexitanimation "> @null </item> <item name=" android:taskopenenteranimation "> @null </ item> <item name= "android:taskopenexitanimation" > @null </item> <item name= "Android:taskcloseenter Animation "> @null </item> <item name=" android:taskcloseexitanimation "> @null </item> <item nam E= "Android:tasktofrontenteranimation" > @null </item> <item name= "Android:tasktofrontexitanimation" > @null </item> <item name= "Android:tasktobackenteranImation "> @null </item> <item name=" android:tasktobackexitanimation "> @null </item> </style >

5, if you need to implement the effect of GIF, prevent the start page of the picture may extend to the status bar, I added a placeholder layout (height for dynamically obtained system status bar height, code is in the start page to get height).

@Override public
  void Onwindowfocuschanged (Boolean hasfocus) {
    super.onwindowfocuschanged (hasfocus);
    int statusbarheight = Getstatusbarheight ();
    Preferencesutil.putint (This, preferencekey.setting, Preferencekey.status_bar_height,
        statusbarheight);
    LOGUTIL.E (Statusbarheight + "");
  }

  public int getstatusbarheight () {
    int = 0;
    int ResourceID = Getresources (). Getidentifier ("Status_bar_height", "Dimen", "Android");
    if (ResourceID > 0) {result
      = Getresources (). Getdimensionpixelsize (ResourceID);
    }
    return result;
  }

The above is a small series for you to bring the activity to cancel the default interface of the animation method (recommended) All content, I hope that we support cloud Habitat Community ~

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.