Android 设置默认主题

Android 设置默认主题,android,Android,我开始使用Android Studio,我注意到有默认的主题材质Dark->Material 一段时间后,创建新项目后,所有视图都从预览中消失。我不知道为什么,但最后我发现主题变成了AppTheme 现在我想再次将默认主题设置为material。我看没有其他选择。很多google链接都指示我将IDE主题设置为IntelliJ或Darcula(这不是我想要做的) 在AndroidManifest.xml中,我无法在编写主题(点)后获取材料 minSdkVersion设置为15,compileS

我开始使用Android Studio,我注意到有默认的主题材质Dark->Material

一段时间后,创建新项目后,所有视图都从预览中消失。我不知道为什么,但最后我发现主题变成了AppTheme

现在我想再次将默认主题设置为material。我看没有其他选择。很多google链接都指示我将IDE主题设置为IntelliJ或Darcula(这不是我想要做的)

在AndroidManifest.xml中,我无法在编写主题(点)后获取材料


minSdkVersion设置为15,compileSdkVersion设置为28

Edit1:每次我在文本模式下添加另一个视图时,主题都会更改为AppTheme。然后我在预览中什么也看不到,直到我改变了素材的主题


如何为我的应用程序项目设置默认材质暗->材质?

您需要在清单中定义活动主题。如果要更改特定活动的主题,请按如下方式编辑活动声明:

<activity
    android:name=".MainActivity"
    android:theme="@style/AppTheme">
</activity>

其中AppTheme是在styles.xml中定义的主题

如果要为所有活动设置默认主题,请将android:theme添加到应用程序标记中

<application
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">

其中AppTheme是styles.xml中的主题

这些属性将强制预览随时加载您的主题

注意:由于兼容性,您应该使用Theme.AppCompat


编辑:我没有仔细阅读你的问题。在清单中,您可以对材质主题使用
android:theme=“@android:style/theme.Material”
。或者更好,为了兼容性,
android:theme=“@style/theme.AppCompat”

我仍然没有在
主题中看到材质暗->材质。
@pochmunik请参见编辑。材质主题必须以
@android:style/theme开头。
<application
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">