您的位置:首页 > 移动开发 > Android开发

[Android]设置Activity为全屏显示的两种方法

2016-07-21 10:36 821 查看
1. 方法1:AndroidManifest.xml 里,Activity的 android:theme 指定为"
@android :style/Theme.NoTitleBar.Fullscreen"

示例:

<application

android:icon="@drawable/ic_launcher"

android:label="@string/app_name"

android:theme="
@android :style/Theme.NoTitleBar.Fullscreen">

<activity

android:name=".MainActivity">

<intent-filter>

<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />

</intent-filter>

</activity>

</application>

2. 方法2: 在onCreate()里指定No title

要加入:

/*set it to be no title*/

requestWindowFeature(Window.FEATURE_NO_TITLE);

/*set it to be full screen*/

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,

WindowManager.LayoutParams.FLAG_FULLSCREEN);

示例:

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

/*set it to be no title*/

requestWindowFeature(Window.FEATURE_NO_TITLE);

/*set it to be full screen*/

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,

WindowManager.LayoutParams.FLAG_FULLSCREEN);

setContentView(R.layout.activity_main);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: