android--Lock horizontal screen, vertical screen, go to title full screen

Source: Internet
Author: User

in the XML file, set:

To achieve this, simply declare the activity in Androidmanifest.xml with an attribute: Android:screenorientation, the property value landscape fixed horizontal screen, The portrait is a fixed vertical screen.

<!--android:screenorientation= "portrait" vertical Screen android:screenorientation= "landscape" horizontal screen android:screenorientation= "Unspecified" does not indicate direction             --<activity android:label= "@string/app_name"             android:name= ". Lockthescreenactivity "             android:screenorientation=" Portrait "   

b) The code is implemented as follows:

 @Override public void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setrequestedorientation (Activityinfo.screen_orientation_landscape);//cross-screen//setrequestedorientation (     activityinfo.screen_orientation_portrait) Vertical screen Setcontentview (r.layout.main); } 
When the screen is automatically switched, the default state of the application will recall OnCreate, which is equivalent to restarting the application once. At the same time, layout may cause a problem that cannot be properly adapted by horizontal screen. In order to solve The program restart problem caused by Rotary screen and keyboard switching, an additional attribute is required: android:configchanges. This property can be understood as a listener that will intercept the spin screen and keyboard switching events, preventing the program from restarting and becoming the callback Onconfigurationchanged method. The properties commonly used here are : keyboardhidden|orientation.

Go to the title

<span style= "FONT-SIZE:14PX;" >public void OnCreate (Bundle savedinstancestate) {         super.oncreate (savedinstancestate);     This.requestwindowfeature (Window.feature_no_title);  } </span>
Full Screen
<span style= "FONT-SIZE:14PX;" >public void OnCreate (Bundle savedinstancestate) {         super.oncreate (savedinstancestate);  This.getwindow (). SetFlags (WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_ fullscreen);  } </span>



android--Lock horizontal screen, vertical screen, go to title full screen

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.