Android Full Screen related actions

Source: Internet
Author: User
<span id="Label3"></p><p><p>1. Hide the title bar (titlebar)</p></p><p><p>(1) hide the title bar in your code</p></p><pre><pre>Requestwindowfeature (window.feature_no_title);</pre></pre><p><p>(2) Configuring theme styles in application or activity in manifest</p></p><pre><pre>Android:theme= "@android: style/theme.notitlebar"</pre></pre><p><p>2. Hide the status bar (statusbar)<br>(1) Configuring theme styles in activity in manifest</p></p><pre><pre>Android:theme= "@android: style/theme.notitlebar.fullscreen"</pre></pre><p><p>(2) Hide the status bar in code</p></p><pre><pre> <span style="color: #008000;">/**</span> <span style="color: #008000;"> * Hide status bar </span> * <span style="color: #008000;"></span> /<span style="color: #0000ff;">private</span><span style="color: #0000ff;">void</span> <span style="color: #000000;"> hidestatusbar () {</span><span style="color: #008000;">// </span> <span style="color: #008000;">define full-screen parameter</span> <span style="color: #0000ff;">int</span> flag =<span style="color: #000000;"> WindowManager.LayoutParams.FLAG_FULLSCREEN; </span> <span style="color: #008000;">//</span> <span style="color: #008000;">get the current form object</span> window window = Mainactivity. <span style="color: #0000ff;"></span> this <span style="color: #000000;">. GetWindow (); </span> <span style="color: #008000;">//</span> <span style="color: #008000;">set the current form to full screen</span> <span style="color: #000000;"> window.setflags (flag, flag); }</span></pre></pre><p><p>3. Hide the navigation bar (navigationbar)</p></p><pre><pre>   <span style="color: #008000;">/**</span> <span style="color: #008000;"> * Hide Navigation bar, can return </span> <span style="color: #008000;">*</span> /<span style="color: #0000ff;">private</span><span style="color: #0000ff;">void</span> <span style="color: #000000;"> hidenavigationbarcanback () { </span>=<span style="color: #000000;"> GetWindow (). getdecorview (); </span> <span style="color: #0000ff;">int</span> uioptions =<span style="color: #000000;"> view.system_ui_flag_hide_navigation </span>| <span style="color: #000000;"> view.system_ui_flag_fullscreen; Decorview.setsystemuivisibility (uioptions); }</span></pre></pre><p><p>4. Hide the status bar and navigation bar at the same time</p></p><pre> <span style="color: #008000;"><span style="color: #008000;">/**</span></span><span style="color: #008000;"><span style="color: #008000;">* Hide Navigation bar</span></span><span style="color: #008000;"><span style="color: #008000;">*/</span></span> <span style="color: #0000ff;"><span style="color: #0000ff;"></span> public</span> <span style="color: #0000ff;"><span style="color: #0000ff;">void</span></span><span style="color: #000000;"><span style="color: #000000;">Hidenavigationbarandstatusbar () {</span></span><span style="color: #0000ff;"><span style="color: #0000ff;">int</span></span>Uiflags =<span style="color: #000000;"><span style="color: #000000;">view.system_ui_flag_layout_stable</span></span>|<span style="color: #000000;"><span style="color: #000000;">view.system_ui_flag_layout_hide_navigation</span></span>|<span style="color: #000000;"><span style="color: #000000;">View.system_ui_flag_layout_fullscreen</span></span>| View.system_ui_flag_hide_navigation<span style="color: #008000;"><span style="color: #008000;">//</span></span><span style="color: #008000;"><span style="color: #008000;">Hide nav Bar</span></span>| view.system_ui_flag_fullscreen;<span style="color: #008000;"><span style="color: #008000;">//</span></span><span style="color: #008000;"><span style="color: #008000;">Hide Status bar</span></span> <span style="color: #0000ff;"><span style="color: #0000ff;">if</span></span>(android.os.Build.VERSION.SDK_INT >= 19<span style="color: #000000;"><span style="color: #000000;">) { </span></span><span style="color: #008000;"><span style="color: #008000;">//</span></span><span style="color: #008000;"><span style="color: #008000;">system_ui_flag_immersive_sticky:hide navigation bars-compatibility:building API level are lower thatn, use magic Number directly for higher API target</span> level</span>Uiflags |= 0x00001000<span style="color: #000000;"><span style="color: #000000;">; } </span></span><span style="color: #0000ff;"><span style="color: #0000ff;">Else</span></span><span style="color: #000000;"><span style="color: #000000;">{uiflags</span></span>|=<span style="color: #000000;"><span style="color: #000000;">view.system_ui_flag_low_profile; } GetWindow (). Getdecorview (). setsystemuivisibility (uiflags); }</span></span></pre><p><p>5. Dynamic fullscreen and exit</p></p><pre> <span style="color: #008000;"><span style="color: #008000;">/**</span></span><span style="color: #008000;"><span style="color: #008000;">* Dynamic Settings fullscreen</span></span><span style="color: #008000;"><span style="color: #008000;">*/</span></span> <span style="color: #0000ff;"><span style="color: #0000ff;">Private</span></span> <span style="color: #0000ff;"><span style="color: #0000ff;">void</span></span><span style="color: #000000;"><span style="color: #000000;">dynamicfullscreen () {windowmanager.layoutparams attrs</span></span>=<span style="color: #000000;"><span style="color: #000000;">GetWindow (). getattributes (); Attrs.flags</span></span>|=<span style="color: #000000;"><span style="color: #000000;">WindowManager.LayoutParams.FLAG_FULLSCREEN; GetWindow (). setattributes (attrs); GetWindow (). addflags (WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); } </span></span><span style="color: #008000;"><span style="color: #008000;">/**</span></span><span style="color: #008000;"><span style="color: #008000;">* Dynamic exit full screen</span></span><span style="color: #008000;"><span style="color: #008000;">*/</span></span> <span style="color: #0000ff;"><span style="color: #0000ff;">Private</span></span> <span style="color: #0000ff;"><span style="color: #0000ff;">void</span></span><span style="color: #000000;"><span style="color: #000000;">dynamicexitfullscreen () {windowmanager.layoutparams attrs</span></span>=<span style="color: #000000;"><span style="color: #000000;">GetWindow (). getattributes (); Attrs.flags</span></span>&= (~<span style="color: #000000;"><span style="color: #000000;">WindowManager.LayoutParams.FLAG_FULLSCREEN); GetWindow (). setattributes (attrs); GetWindow (). clearflags (WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); }</span></span></pre><p><p></p></p><p><p>Android Full Screen related actions</p></p></span>

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.