当前位置: 移动技术网 > 移动技术>移动开发>Android > Android 开发隐藏标题栏的方法总结

Android 开发隐藏标题栏的方法总结

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

android 开发隐藏标题栏的方法总结

1. 推荐!(因为现在工程都默认的为apptheme)

在value/styles.xml里面添加自定义属性

<resources xmlns:android="http://schemas.android.com/apk/res/android">
  <!-- application theme. -->
  <style name="apptheme" parent="appbasetheme">
    <item name="android:windownotitle">true</item>
</resources>

 2.

public class mainactivity extends activity{
  @override
  protected void oncreate(bundle savedinstancestate){
    super.oncreate(savedinstancestate);
    // 隐藏标题栏
    requestwindowfeature(window.feature_no_title);
    // 隐藏状态栏
    getwindow().setflags(windowmanager.layoutparams.flag_fullscreen,
    windowmanager.layoutparams.flag_fullscreen);
    //一定要放在setcontentview()之前!
    setcontentview(r.layout.activity_main);
  }
}

3.

<!-- 同时隐藏状态栏和标题栏 -->
<activity
  android:name="com.ysj.demo.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>
 

4.打开项目文件androidmanifest.xml ,打开application选择tab页,在页面下方的application nodes中点选择相应的类,   配置右侧的theme属性。

在弹出选择框中点选"system resources",选择theme.notitlebar项目,然后重新打开页面就行了

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网