Resolve activity start black screen and set android:windowistranslucent incompatible activity Toggle Animation problem

Source: Internet
Author: User

Before the project encountered a black screen after opening the activity, the solution is found online by setting the theme and style properties can be achieved.

Http://www.cnblogs.com/sunzn/p/3407078.html

application   Theme style Android:theme = "@style/apptheme"   Use of  THEME.LIGHT 

<stylename= "Apptheme"Parent= "Android:Theme.Light">

</style>

After simple modification, the splash screen color is black, the code is as follows:

<stylename= "Apptheme"Parent= "Android:style/theme.black.notitlebar.fullscreen">     </style>

The code has been modified to refer to a black theme, but the Welcome page will still have a short pause on the black splash screen. Continue with the modification, set the Transparency property to true and the code is as follows:

    <stylename= "Apptheme"Parent= "Android:style/theme.black.notitlebar.fullscreen">        <Itemname= "Android:windowistranslucent">True</Item>    </style>

After this modification, the black splash screen disappears and finally achieves its desired effect. Finally, after consulting the data found that some people have summed up and dealt with this kind of problem, and give the pros and cons of the analysis, I am here with my understanding of the reference.

There are 2 ways to avoid the black splash screen: 1. Set the background map for Theme ; 2. Set the transparency property for Theme . Obviously I'm using the second approach, and I'll look at the code referenced in these 2 different ways:

    <!--set a background map for Theme -    <stylename= "Apptheme"Parent= "Android:style/theme.black.notitlebar.fullscreen">        <Itemname= "Android:windowbackground">@drawable/SPLASH_BG</Item>    </style>
    <!--set transparent properties for Theme -    <stylename= "Apptheme"Parent= "Android:style/theme.black.notitlebar.fullscreen">        <Itemname= "Android:windowistranslucent">True</Item>    </style>

2 Theme above, for  THEME&NBSP; After setting the background map, the program will display this image first, to avoid the black screen; theme   Set transparent properties, the program will not be black screen but transparent after startup, until the interface initialization is complete before it is displayed once. Here are the pros and cons of two ways:

  • < Span style= "margin:0px; padding:0px; font-size:13px; Color:rgb (255,0,0) ">  THEME&NBSP; set background image        give the program a quick feel, the interface first shows the background map, and then refresh the other interface controls, refresh the different steps.
  • Set the transparent properties for Theme The program starts slowly, the interface will be brushed out at once, refresh the synchronization.

However, the problem has arisen, originally in the configuration of the activity of the switch animation effect, set up the android:windowistranslucent=true after the switch animation is invalid. For the time being I don't know the intricacies of the relationship between the theme properties of the Android system, inheriting to inherit ... Why this kind of problem, but fortunately inadvertently found a solution

<style name= "Apptheme" parent= "Appbasetheme" > <!--<item name= "Android:windowanimationstyle" > @style/ Animation.activity.style</item>--<item name= "Android:windowanimationstyle" > @style/ animation.activity.translucent.style</item> <item name= "Android:windowbackground" > @android: color/ transparent</item> <item name= "android:windowistranslucent" >true</item> </style> < Style name= "Animation.Activity.Style" parent= "@android: style/animation.activity" > <item name= "android:activi Tyopenenteranimation "> @anim/base_slide_right_in</item> <item name=" android:activityopenexitanimation "> @anim/base_stay_orig</item> <item name=" android:activitycloseenteranimation "> @anim/base_stay_        orig</item> <item name= "android:activitycloseexitanimation" > @anim/base_slide_right_out</item> <item name= "Android:taskopenenteranimation" >@anim/base_slide_right_in</item> <item name= "android:taskopenexitanimation" > @anim/base_stay_orig< /item> <item name= "android:taskcloseenteranimation" > @anim/base_stay_orig</item> <item name = "Android:taskcloseexitanimation" > @anim/base_slide_right_out</item> <item name= "Android: Tasktofrontenteranimation "> @anim/base_slide_right_in</item> <item name=" Android: Tasktofrontexitanimation "> @anim/base_stay_orig</item> <item name=" Android:tasktobackenteranimation "& gt; @anim/base_stay_orig</item> <item name= "android:tasktobackexitanimation" > @anim/base_slide_right_ out</item> </style> <style name= "Animation.Activity.Translucent.Style" parent= "@android: style/ Animation.translucent "> <item name=" android:windowenteranimation "> @anim/base_slide_right_in</item > <item name= "android:windowexitanimation" > @anim/base_slide_right_out</item> </style> 

Configure the style to inherit the parent as

<style name= "Animation.Activity.Translucent.Style" parent= "@android: Style/animation.translucent" >        < Item Name= "Android:windowenteranimation" > @anim/base_slide_right_in</item>        <item name= "Android: Windowexitanimation "> @anim/base_slide_right_out</item>    </style>

And let Apptheme's
Android:windowanimationstyle for the style above

<style name= "Apptheme" parent= "Appbasetheme" >        <item name= "Android:windowanimationstyle" > @style/ animation.activity.translucent.style</item>        <item name= "Android:windowbackground" > @android: color/transparent</item>        <item name= "android:windowistranslucent" >true</item>    </ Style>

If you want to use the theme during all activity switching, you can configure application, or you can configure the activity in a single individual configuration.

Of course, when the homepage exits, you can configure mainactivity exit animation and enter the animation separately.

<style name= "Animation.Activity.Translucent.Style.Main" parent= "@android: Style/animation.translucent" >        <item name= "android:windowexitanimation" > @anim/slide_right_out</item>    </style>


Mainactivity's exit and entry animations can be referenced by the system, but it seems that the anim in the style does not refer to some systems,

Under Folder Sdk\platforms\android-20\data\res, Activity_open_enter.xml,activity_close_exit.xml can be copied directly into the project, modifying

Write a separate entry or exit, and then other defaults ....

More hands-on, testing, if there are errors in the place trouble message to exchange, thank you

Copy to Google TranslateTranslation ResultsRobot:Windowanimationstyle

Resolve activity start black screen and set android:windowistranslucent incompatible activity Toggle Animation problem

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.