软件编程
位置:首页>> 软件编程>> Android编程>> Android Studio实现标题栏和状态栏的隐藏

Android Studio实现标题栏和状态栏的隐藏

作者:谈谈的心情  发布时间:2022-11-29 08:45:10 

标签:android,标题栏,状态栏

Android Studio在实现隐藏标题栏和状态栏上和Eclipse是完全不一样的。

在Eclipse上隐藏标题栏和状态栏的代码如下:

方法一: requestWindowFeature(Window.FEATURE_NO_TITLE);

方法二:getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,


WindowManager.LayoutParams.FLAG_FULLSCREEN);

今天在做闪屏页开发时,想把标题栏和状态栏隐藏掉,但这两种方法尝试后都不行。

最后的解决方案:

①先在values的styles.xml中添加子标签:


<style name="NoTitle" parent="Theme.AppCompat.DayNight.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
</style>

②在清单文件中,需要隐藏标题栏和状态栏的Activity引用此样式:


<activity android:name=".SplashActivity" android:theme="@style/NoTitle">

经过这两步,便是一个没有标题栏和状态栏的完美闪屏页了!

PS:下面看下Android Studio 去掉标题栏状态栏的完整代码

**网上关于Android Studio的教程比较少,去掉标题栏的方法大多不能直接使用。

在Android Studio中其实更简单一些,在app/res/values/styles.xml文件中加个标签就可以了**


<item name="windowNoTitle">true</item>

完整代码如下,可以看到这段代码放在什么位置。


<resources>
 <!-- Base application theme. -->
 <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
  <!-- Customize your theme here. -->
  <item name="colorPrimary">@color/colorPrimary</item>
  <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
  <item name="colorAccent">@color/colorAccent</item>
  <item name="windowNoTitle">true</item>
 </style>
</resources>

加到 加载视图前面


//取消状态栏
 getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);

总结

以上所述是小编给大家介绍的Android Studio实现标题栏和状态栏的隐藏网站的支持!

来源:http://blog.csdn.net/ljw124213/article/details/52743486

0
投稿

猜你喜欢

手机版 软件编程 asp之家 www.aspxhome.com