Android two ways to set full screen activity
•
Android
The first is to set it in our code, as shown in the following two lines of code:
However, these two pieces of code must be declared before setcontentview (r.layout. Main). You must pay attention to this paragraph, otherwise it may not succeed. Without much gossip, here is the code:
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //没有title,在activity是不会出现标题 requestWindowFeature(Window.FEATURE_NO_TITLE); //activity产生之前,就已经可以全屏的操作 getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.main); }
mainfest文件配置代码<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.guchan" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="10" /> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <activity android:label="@string/app_name" android:name=".QQblogActivity" <!--主要就是这里的配置这个activity的样式即可--> android:theme="@android:style/Theme.NoTitleBar.Fullscreen" > <intent-filter > <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>
Reproduced at: https://www.cnblogs.com/alterhu/archive/2011/10/30/2229179.html
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码