展会信息港展会大全

android开发中设置Activity为全屏显示的两种方法
来源:互联网   发布日期:2016-01-14 10:21:37   浏览:2330次  

导读:1 方法1:AndroidManifest xml 里,Activity的 android:theme 指定为 @android :style Theme NoTitleBar Fullscreen示例: application android:icon=@drawable ic_launcher android: ...

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);

赞助本站

人工智能实验室

相关热词: 全屏显示 Activity android

AiLab云推荐
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港