当前位置: 移动技术网 > IT编程>移动开发>Android > Android 实现全屏和无标题栏的显示

Android 实现全屏和无标题栏的显示

2019年07月24日  | 移动技术网IT编程  | 我要评论

年票车船税,飞机撒药治白蛾,绣花鞋电影下载

在android实现没有标题栏的方法有两种:

在代码中添加

requestwindowfeature(window.feature_no_title); 

在清单文件androidmanifest.xml中添加

android:theme="@android:style/theme.notitlebar" 

具体的代码如下:

第一种:

mainactivity.java
package com.lingdududu.test; 
 
import android.app.activity; 
import android.os.bundle; 
import android.view.window; 
 
public class mainactivity extends activity { 
 /** called when the activity is first created. */ 
 private boolean catchhomekey = false; 
 public void oncreate(bundle savedinstancestate) { 
 super.oncreate(savedinstancestate); 
 this.requestwindowfeature(window.feature_no_title); 
 setcontentview(r.layout.main); 
  
 } 
} 

第二种:

androidmanifest.xml
<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
 package="com.lingdududu.test" 
 android:versioncode="1" 
 android:versionname="1.0"> 
 <uses-sdk android:minsdkversion="10" /> 
 
 <application android:icon="@drawable/icon" android:label="@string/app_name"> 
 <activity android:name=".mainactivity" 
   android:label="@string/app_name" 
   android:theme="@android:style/theme.notitlebar" > 
  <intent-filter> 
  <action android:name="android.intent.action.main" /> 
  <category android:name="android.intent.category.launcher" /> 
  </intent-filter> 
 </activity> 
 
 </application> 
</manifest> 

效果图:

如果想让窗口全屏显示:

将下面两段代码分别替换上面的两段设置无标题的代码就可以了

getwindow().setflags(windowmanager.layoutparams. flag_fullscreen ,   
  windowmanager.layoutparams. flag_fullscreen); 
 
android:theme="@android:style/theme.notitlebar.fullscreen" 

效果图:

 以上就是对android 全屏效果的代码实例,和效果显示,希望能帮助到大家。

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网