[英]Cannot find “Theme.Material” in android studio
When I create a new Project in Android Studio, the dafault app theme is "Theme.appCompat.light".当我在 Android Studio 中创建一个新项目时,dafault 应用程序主题是“Theme.appCompat.light”。 Whene I try to set "Theme.Material" as theme in the manifest Android Studio shows me no suggestion, and finds no "Theme.Material".当我尝试在清单中将“Theme.Material”设置为主题时,Android Studio 没有显示任何建议,也没有找到“Theme.Material”。 I updated everything in the sdk manager.我更新了 SDK 管理器中的所有内容。 What have I to do to use Material Theme?我需要做什么才能使用 Material Theme?
To be able to use all of Theme.Material
you should:为了能够使用所有Theme.Material
您应该:
compileSdkVersion
is set to at least 21.确保compileSdkVersion
至少设置为 21。dependencies
you have compile 'com.android.support:design:24.0.0'
确保在您的dependencies
您已compile 'com.android.support:design:24.0.0'
Both of these can be found on your build.gradle (Module: app)
file.这两个都可以在你的build.gradle (Module: app)
文件中找到。
After that you can apply Material Theme simply by going to your AndroidManifest.xml
file and inside <application>
tag make sure you have a line that says android:theme="@android:style/Theme.Material.Light"
.之后,您只需转到您的AndroidManifest.xml
文件并在<application>
标签内确保您有一行显示android:theme="@android:style/Theme.Material.Light"
即可应用 Material Theme。
It won't show up if you just use @style/Theme.Material
like with how you'd normally use @style/Theme.AppCompat
.它不会显示出来,如果你只需要使用@style/Theme.Material
像如何你通常使用@style/Theme.AppCompat
。
Theme.Material
requires you to use @android:style/Theme.Material
. Theme.Material
要求您使用@android:style/Theme.Material
。
您在android
闭包中的compileSdkVersion
需要为 21 或更高才能引用Theme.Material
。
此外,如果 AS 编辑器中的 API 版本低于 21,则在尝试更改特定布局的主题时弹出的选择主题窗口中,材质深色和浅色主题部分将为空。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.