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.