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去除栏内容请搜索编程网以前的文章或继续浏览下面的相关文章希望大家以后多多支持编程网!