Remove the title bar of Android to enable full screen and rotate the screen.

Source: Internet
Author: User

Remove the title bar of Android to enable full screen and rotate the screen.

This is a very common problem. In fact, it is very simple. I will not talk about it much, but I will go directly to the code.

Public class MainActivity extends Activity {@ Override protected void onCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState); requestWindowFeature (Window. FEATURE_NO_TITLE); // remove the title getWindow (). setFlags (WindowManager. layoutParams. FLAG_FULLSCREEN, WindowManager. layoutParams. FLAG_FULLSCREEN); // setContentView (R. layout. activity_main); Button Btn = (Button) findViewById (R. id. btn); Btn. setOnClickListener (new View. onClickListener () {@ Override public void onClick (View arg0) {Configuration Cfg = getResources (). getConfiguration (); if (Cfg. orientation = Configuration. ORIENTATION_LANDSCAPE) // If the screen is landscape {MainActivity. this. setRequestedOrientation (ActivityInfo. SCREEN_ORIENTATION_PORTRAIT);} else if (Cfg. orientation = Configuration. ORIENTATION_PORTRAIT) // if it is a portrait screen {MainActivity. this. setRequestedOrientation (ActivityInfo. SCREEN_ORIENTATION_LANDSCAPE );}}});}
I solemnly declare the following: I. This article from the CSDN blog, portal: http://BlOG.CSDN.NET/Yirancpp Ii. All Rights Reserved. This statement cannot be removed when any individual or website reposts this article. 3. You are not allowed to modify the document unless explicitly stated. You are also welcome to repost and share your comments.

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.