Android应用设置全屏的方法

一般在设置Android应用全屏显示有三种方法

第一种是代码实现

	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		//设置无Title
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		//设置应用全屏,必须写在setContentView方法前面!!!记得!
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
		setContentView(R.layout.activity_main);


第二种是在AndroidManifest,xml清单配置文件里配置

在相应的Activity中节点中添加属性:android:theme="@android:style/Theme.NoTitleBar.Fullscreen" 即可以设置某个Activity全屏显示。若设置成 android:theme="@android:style/Theme.NoTitleBar" 即是只是设置成无标题状态。
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.expandablelistview.MainActivity"
            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>

第三种方法是自定义全屏Theme

在style.xml文件中定义theme(如果没有style.xml,在res/values目录下创建)
<resources> 
    <style name="Theme.NoTitle_FullScreen"> 
        <item name="android:windowNoTitle">true</item>    
        <item name="android:windowFullscreen">true</item>      
    </style> 
</resources>
然后直接在AndroidManifest.xml中需要全屏显示的Activity属性中添加
android:theme="@style/Theme.NoTitle_FullScree"


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值