Full screen in the activity's OnCreate methodbefore Setcontentview (myview) CallAdd the following code
Requestwindowfeature (window.feature_no_title);//Hide Title GetWindow (). SetFlags (WindowManager.LayoutParams.FLAG_ Fullscreen, WindowManager.LayoutParams.FLAG_FULLSCREEN);//Set Full screen
Horizontal screen Modify the activity's Onresume method as shown in the following code example
@Overrideprotected void Onresume () {/** * is set to horizontal screen */ if (getrequestedorientation ()!=activityinfo.screen_ Orientation_landscape) { setrequestedorientation (activityinfo.screen_orientation_landscape);} super.onResume ();}
Or add the Android:screenorientation property to the Activity node in the configuration file (landscape is landscape, portrait is portrait)
Android:launchmode= "Singletask" android:screenorientation= "Portrait" >
To set the vertical screen to screen_orientation_portrait//----------------solid View.setkeepscreenon (true) without any processing code to rotate the screen, Rotating the screen will cause the system to close the current activity and reopen it.
If it is just a simple interface adjustment, we can prevent this problem from happening, the screen rotates while the element refactoring itself adjusts the screen.
First we need to modify the Androidmanifest.xml file:
<activity android:name= ". Magazine ">
</activity>
Modified to:
<activity android:name= ". Magazine "
android:configchanges= "Orientation|keyboard" >
</activity>
This allows the program to respond to events that rotate the screen.
Then rewrite the Onconfigurationchanged method:
@Override
public void onconfigurationchanged (Configuration newconfig) {
TODO auto-generated Method Stub
Super.onconfigurationchanged (Newconfig);
LOG.V ("= = onconfigurationchanged");
Processlayout ();
}//----------------------------in our development process with Android,will encounter activity in switching to the background or layout from the horizontal screen landscape switch to portrait, will re-switch activity will trigger a OnCreate method. In Android development This situation can be avoided, we can add this attribute to the Activit element in Androidmanifest.xml android:configchanges= "orientation| Keyboardhidden "can effectively avoid the Oncreat method of repeated loading, androidmanifest.xml content is as follows: The red font is added part <?xml version=" 1.0 "encoding=" Utf-8 "? >
<manifest xmlns:android= "Http://schemas.android.com/apk/res/android"
Package= "Com.demo"
Android:versioncode= "1"
Android:versionname= "1.0" >
<application android:icon= "@drawable/icon" android:label= "@string/app_name" >
<activity android:name= ". Demogps "
android:configchanges= "Orientation|keyboardhidden"
Android:label= "@string/app_name" >
<intent-filter>
<action android:name= "Android.intent.action.MAIN"/>
<category android:name= "Android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<uses-library android:name= "Com.google.android.maps"/> </application>
<USES-SDK android:minsdkversion= "7"/> <uses-permission android:name= "Android.permission.INTERNET" > </uses-permission>
<uses-permission android:name= "Android.permission.ACCESS_COARSE_LOCATION" ></uses-permission>
<uses-permission android:name= "Android.permission.ACCESS_FINE_LOCATION" ></uses-permission>
</manifest> also overloads the Onconfigurationchanged (Configuration newconfig) method in the activity's Java file so that it does not overload during layout switching or window switching. The code is as follows: @Override
public void onconfigurationchanged (Configuration newconfig)
{
Super.onconfigurationchanged (Newconfig);
if (This.getresources (). GetConfiguration (). Orientation = = Configuration.orientation_landscape)
{
Land
}
else if (this.getresources (). GetConfiguration (). Orientation = = configuration.orientation_portrait)
{
Port
}
}//------------------------------------------------------The problem of the screen switching between activity in Android can be done through the activity in the Androidmanifest.xml file Configuration:
android:screenorientation=["Unspecified" | "User" | "Behind" |
"Sensor" | "Nonsensor"]
Screenorientation is used to specify the direction in which activity is displayed on the device, each of which represents the following meanings:
" unspecified " |
default value The display direction is judged by the system. The decision strategy is device-dependent, so different devices will have different display orientations. |
" landscape " |
horizontal display (width to height) |
" portrait "/ code> " |
vertical display (high width to long)
|
" user " |
user's current preferred orientation |
" behind " |
and the AC Tivity The following activity is in the same direction (in the activity stack) |
" sensor "/ code> " |
has a physical sensor to determine. If the user rotates the device, the screen will switch between the screens. |
" nosensor " |
ignores physical sensors, This does not change as the user rotates the device (" unspecified " setting). |
Excerpt from http://2960629.blog.51cto.com/2950629/701227