这篇文章主要介绍了android开发去除标题栏的方法,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
1:新建一个项目运行起来,可以看到顶部一直有个标题栏看着不是很美观

2:有两种方法可以去除顶部标题栏
(1)将代码中AndroidManifest里android:theme="@style/Theme.MyApplication"改为android:theme="@style/Theme.AppCompat.NoActionBar">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.AppCompat.NoActionBar"
>
(2)在themes.xml文件里改,选中MyApplication,Ctrl+鼠标点击

来到themes.xml文件里,把代码中parent="Theme.MaterialComponents.DayNight.DarkActionBar"替换为
parent=“Theme.AppCompat.Light.NoActionBar”
<style name="Theme.MyApplication" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_500</item>
<item name="colorPrimaryVariant">@color/purple_700</item>
<item name="colorOnPrimary">@color/white</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/teal_200</item>
<item name="colorSecondaryVariant">@color/teal_700</item>
<item name="colorOnSecondary">@color/black</item>
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
</style>
3:效果展示

到此这篇关于android开发去除标题栏的文章就介绍到这了,更多相关android去除标题栏内容请搜索编程学习网以前的文章希望大家以后多多支持编程学习网!
织梦狗教程
本文标题为:android开发去除标题栏的方法
基础教程推荐
猜你喜欢
- Android多返回栈技术 2023-04-15
- IOS 播放系统提示音使用总结(AudioToolbox) 2023-03-01
- Flutter绘图组件之CustomPaint使用详解 2023-05-12
- 解决Android Studio突然不显示logcat日志的问题 2023-02-04
- Flutter手势密码的实现示例(附demo) 2023-04-11
- Android开发使用RecyclerView添加点击事件实例详解 2023-06-15
- Android中的webview监听每次URL变化实例 2023-01-23
- IOS应用内跳转系统设置相关界面的方法 2022-11-20
- iOS开发教程之XLForm的基本使用方法 2023-05-01
- android studio按钮监听的5种方法实例详解 2023-01-12
