Android Development hides the Actionbar still short flash solution

Source: Internet
Author: User

Sometimes we hide the Actionbar in the code, and when we open the app, it's still a short flash of actionbar, and the user experience is bad.

 The simplest way to do this is to set the theme in Androidmanifest.xml to not show the title or action, which is: <style name= "Notitle" parent= "Android:Theme.Holo.Light" ><item name= "Android:windowactionbar" >true</item></style> or <style name= "Notitle" parent= "Android:Theme.Holo.Light" ><item name= "Android:windownotitle" >true</item></style> but sometimes, if you want to show Actionbar, you can not set in androidmanifest.xml so, I tried, do the above settings, can not show actionbar (this I try the result is so, there can be displayed please give me a reply), at this time, how to solve this problem, in StackOverflow see there is a solution, posted here: Setting Android:windowactionbar=false truly disables the ActionBar and then, as you say, Getactionbar () returns NULL. this was solved by: Public void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate);GetWindow (). Requestfeature (Window.feature_action_bar);Getactionbar (). Hide (); Setcontentview (R.layout.splash);//Be sure-the-after Requestfeature But now there is another problem. After putting Windowactionbar=false in the theme, the Activity draws their normal Window Title instead of an ActionBar.If We try to avoid this by using some of the *. Notitlebar stock themes or we try to put true in our own theme, it won ' t work.The reason is and the ActionBar depends on the Window Title to display itself-that are the ActionBar is a transforme D Window Title.So the trick which can help us out are to add one more thing to our Activity theme xml:  <item name= "Android:windowactionbar" >false</item><item name= "android:windowtitlesize" >0dp</item> This would make the Window Title with zero height, thus practically invisible. in your case, after you is done with displaying the splash-can simply call Setcontentview (r.layout.main);Getactionbar (). Show ()And you were done . The Activity would start with no ActionBar flickering, nor Window Title showing

Android Development hides the Actionbar still short flash solution

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.