In actual application development, we sometimes need to set the activity to full screen display. Generally, we can set the full screen display effect in two ways:
First, you can set it in the code,
Second, set full screen through the manifest configuration file.
1. Set it before setcontentview in oncreate code (as follows)
View plaincopy to clipboardprint?
Public void oncreate (bundle savedinstancestate ){
Super. oncreate (savedinstancestate );
// Cancel the title
Requestwindowfeature (window. feature_no_title );
// Cancel the status bar
Getwindow (). setflags (windowmanager. layoutparams. flag_fullscreen,
Windowmanager. layoutparams. flag_fullscreen );
Setcontentview (R. layout. Main );
}
However, you must note that if you set it in the Code, the two sections of code with no title and full screen should be placed in setcontentview (R. layout. main) (interface rendering, but it won't work if the screen is finished) before this code. Otherwise, an error is reported.
Second, set it in the manifest configuration file.
① Create a theme. xml file in the Res/values directory (for style placement)
<? XML version = "1.0" encoding = "UTF-8"?>
<Resources>
<! -- Name is the name of the style, and parent inherits the parent style -->
<Style name = "theme_fullscreen" parent = "Android: theme. Black">
<Item name = "Android: windownotitle"> true </item> <! -- Set no title -->
<Item name = "Android: windowfullscreen">? Android: windownotitle </item> <! --Whether to fill in the slow screen and reference the Android: windownotitle Value? Android: windownotitle, depending on the value of Android: windownotitle -->
</Style>
</Resources>
② <Activity Android: Name = ". login. loginactivity" Android: theme = "@ style/theme_fullscreen"/>
View plaincopy to clipboardprint?
<? XML version = "1.0" encoding = "UTF-8"?>
<Manifest xmlns: Android = "http://schemas.android.com/apk/res/android"
Package = "com. andyidea"
Android: versioncode = "1"
Android: versionname = "1.0" type = "codeph" text = "/codeph">
<Uses-SDK Android: minsdkversion = "8"/>
<Application Android: icon = "@ drawable/icon" Android: Label = "@ string/app_name">
<Activity Android: Name = ". login. loginactivity"
Android: theme = "@ Android: style/theme. notitlebar. fullscreen"
Android: Label = "@ string/app_name">
<Intent-filter>
<Action Android: Name = "android. Intent. Action. Main"/>
<Category Android: Name = "android. Intent. Category. launcher"/>
</Intent-filter>
</Activity>
</Application>
</Manifest>
Set no title for the entire application only in the program title bar.
(Please mail to freeget.one@gmail.com for the latest strong software.)
Third: This is not commonly used in general applications. It is to create a style. xml file under the Res/values directory.For example:
<?xml version="1.0" encoding="UTF-8" ?> <resources><style name="theme_notitle"><item name="android:windowNoTitle">true</item></style></resources>
In this way, we customize a style, which is equivalent to a topic and then defined in the androidmanifest. xml file.
<application android:icon="@drawable/icon" android:label="@string/app_name"android:theme="@style/theme_notitle">
In this way, the title bar can be removed.