问题
Before upgrading to android 3.1
.I usually just change the theme to a theme. app compact. NoTitleBar
but the new version of android studio
is having errors recognizing it.I solved this problem by adding base to the beginning. But I can seem to find any answer regarding a style theme that supports removing the custom bar.
回答1:
Add this style in style file . where other styles are mentioned .
<!-- Base application theme. -->
<style name="AppThemeNoActionBar" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/colorPrimaryDark</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorPrimaryDark</item>
<item name="android:statusBarColor">@color/lightgreycolor</item>
</style>
回答2:
In your res/values/styles.xml
you have this similar block of code.
Ensure that you use Theme.AppCompat.Light.NoActionBar
as parent
of your theme
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
来源:https://stackoverflow.com/questions/52358998/removing-the-default-toolbar-in-an-activity-android