通过java代码隐藏
actionBar.hide()
核心代码
@Override
protected void onCreate(Bundle savedInstanceState) {
...
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.hide();
}
...
}
效果图如下图所示:
修改themes配置文件
将 style
中的 parent
的值修改为 Theme.MaterialComponents.DayNight.NoActionBar.Bridge
<resources xmlns`:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.Game2048" parent="Theme.MaterialComponents.DayNight.NoActionBar.Bridge">
...
</style>
</resources>
通过这种方式也能达到效果