android如何隐藏头部的标题栏全屏显示

本文介绍了两种在Android中实现隐藏标题栏并全屏显示的方法:一种是在Activity的onCreate()中通过代码设置,另一种是在AndroidManifest.xml中为Activity指定NoTitleBar主题。此外,还列举了Android的一些常见主题设置,包括不同背景颜色、标题栏存在与否以及全屏选项。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1)第一种在activity的onCreate中加入:

@Override
protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

//隐藏标题的头部 要放在加载布局文件的上边

requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_add_client_go_and_back);

}


 2)第二种方法是在清单文件AndroidManifest.xml中的activity的的属性中加入:

 android:theme="@android:style/Theme.Light.NoTitleBar"

  <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.Light.NoTitleBar" >
    </application>



附:android的一些Theme设置

   android:theme="@android:style/Theme.Black"  //背景黑色-有标题-非全屏
   android:theme="@android:style/Theme.Black.NoTitleBar" //背景黑色-无标题-非全屏
   android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" //背景黑色-无标题-全屏显示
   android:theme="@android:style/Theme.Dialog" //对话框显示
 
   android:theme="@android:style/Theme.InputMethod"
   android:theme="@android:style/Theme.Light"    //背景白色-有标题-非全屏
   android:theme="@android:style/Theme.Light.NoTitleBar" //背景白色-无标题-非全屏
   android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen" //背景白色-无标题-全屏显示
   android:theme="@android:style/Theme.Light.Panel"
   android:theme="@android:style/Theme.Light.WallpaperSettings" //背景透明
   android:theme="@android:style/Theme.NoDisplay"
   android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" //半透明、无标题栏、全屏
   android:theme="@android:style/Theme.Wallpaper.NoTitleBar.Fullscreen"

 


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值