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中DatePicker和TimePicker的使用方法详解
这篇文章主要介绍了android中DatePicker和TimePicker的使用方法,是Android中常用的功能,需要的朋友可以参考下2014-07-07
Android ImageButton自定义按钮的按下效果的代码实现方法分享
这篇文章主要介绍了Android ImageButton自定义按钮的按下效果的代码实现方法,需要的朋友可以参考下2014-02-02
使用androidx BiometricPrompt实现指纹验证功能
这篇文章主要介绍了使用androidx BiometricPrompt实现指纹验证功能,对android指纹验证相关知识感兴趣的朋友跟随小编一起看看吧2021-07-07


最新评论