Android - 在 xml 中隐藏 Material 主题中的操作栏

标签 android android-5.0-lollipop material-design

我正在使用继承自 "android:Theme.Material.Light" 的主题,但无法找到一种方法来隐藏 xml 样式自定义项中的操作栏。使用 "Theme.AppCompat.Light" 时,我可以用这样的方式来做

<style name="MyTheme" parent="Theme.AppCompat.Light">
    <item name="windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
</style>

如何使用 Material 主题获得类似的结果?我知道你可以通过编程方式隐藏它,但这不仅不方便,因为你实际上无法在 Android Studio 上看到真正的布局,而不必每次都运行该应用程序,而且,当你运行应用程序,在 getActionBar().hide() 运行之前看起来真的很不专业。

解决方案:

<style name="MyTheme" parent="android:Theme.Material.Light">
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowActionBar">false</item>
</style>

最佳答案

<style name="MyTheme" parent="android:Theme.Material.Light.NoActionBar">

关于Android - 在 xml 中隐藏 Material 主题中的操作栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31750440/

相关文章:

Javax SmartCardIO 奇怪错误 6700 长度不正确

java - 如何将多项 Activity 合而为一

android - 如何在布局xml中添加recyclerview

android - "android:elevation="在带有编译 API21 的 Lollipop 前设备上不起作用

reactjs - 如何在material-ui主题中导入和使用自定义字体?

android - 缺少样式。是否为此布局选择了正确的主题?

android - 检索消费项目的历史

android - 如何在 Lollipop 中使用 setOutlineProvider 而不是 setOutline

android - 我可以在对话框中显示 Material 设计 Snackbar 吗?

android - NestedScrollView 滚动滞后,直到 CollapsingToolbarLayout View 不折叠