[英]Android Studio 1.3: Theme.Material.Light and Theme.Material Giving Error
I am trying to make an Android Application with Material Design. 我正在尝试使用Material Design开发一个Android应用程序。 My initial problem was that the v22 styles.xml wasn't present in the values folder. 我最初的问题是,values文件夹中没有v22 styles.xml。 However, I fixed that issue with the following link from Stackoverflow: 但是,我通过Stackoverflow的以下链接修复了该问题:
values-21, values-22 or values-xx folder is gone after Android Studio 1.0 在Android Studio 1.0之后不再显示values-21,values-22或values-xx文件夹
Then, when I changed my new v22 styles.xml theme to Theme.Material.Light, it showed an error and appeared red. 然后,当我将新的v22 styles.xml主题更改为Theme.Material.Light时,它显示了错误并显示为红色。 In the above link, bijang tells Pankaj to download and put a certain themes_material.xml file into the values folder. 在上面的链接中,bijang告诉Pankaj下载并将特定的themes_material.xml文件放入values文件夹中。 The existing Theme.Material.Light error goes away, but in that file (whose source code can be found here: https://gist.github.com/jbj88817/b0a3f750e3fe705a8a1a ) It shows an error as follows: 现有的Theme.Material.Light错误消失了,但是在该文件中(其源代码可以在这里找到: https ://gist.github.com/jbj88817/b0a3f750e3fe705a8a1a)它显示如下错误:
Theme.Material, where THEME is the error. Theme.Material,其中THEME是错误。 Please help! 请帮忙!
Here is my v22 styles.xml: 这是我的v22 styles.xml:
<resources>
<style name="AppTheme" parent = "Theme.Material.Light">
</style>
</resources>
Since after the SDK for api 22 was introduced. 自从引入api 22 SDK之后。 You don't need a separate styles.xml for v22 or v21. 对于v22或v21,您不需要单独的styles.xml。 So in values res folder have only one styles.xml(default one) and to support material design use Theme.AppCompat. 因此,在values文件夹中,res文件夹仅包含一个styles.xml(默认值为一个),并且要使用Material.AppCompat支持材质设计。
Example 例
<style name="AppTheme" parent="Theme.AppCompat">
</style>
And in addition use AppCompatActivity
instead of ActionBarActivity
for your activity. 另外,对于您的活动,请使用AppCompatActivity
而不是ActionBarActivity
。
Example 例
public class MainActivity extends AppCompatActivity
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.