简体   繁体   English

Android创建主题和样式

[英]Android creating themes and styles

I would like to define a theme for my first Android app. 我想为我的第一个Android应用程序定义一个主题。 I use Eclipse and I follow this tutorial but have problems. 我使用Eclipse,并且遵循本教程,但是有问题。

Steps: 脚步:

A. I create the values/styles.xml file with content A.我创建带有内容的values / styles.xml文件

<?xml version="1.0" encoding="utf-8"?>
<resources>
  <style name="default_splashScreen">
    <item name="android:background">@drawable/bg</item>
  </style>
</resources>

B. I create the values/themes.xml file with content B.我创建带有内容的values / themes.xml文件

<?xml version="1.0" encoding="utf-8"?>
<resources>
  <style name="Theme" parent="android:Theme">
    <item name="SplashScreen">@style/default_splashScreen</item>
  </style>
</resources>

Now Eclipse always complains about the item name="SplashScreen" node with the message "No resource found...". 现在,Eclipse总是抱怨项目名称为“ SplashScreen”的节点,并显示消息“找不到资源...”。 I just want SplashScreen to call default_splashScreen style. 我只希望SplashScreen调用default_splashScreen样式。

What is wrong? 怎么了? Thx! 谢谢!

Is Eclipse only complaining in the text editor or also when you actually try to compile and run the app? Eclipse是仅在文本编辑器中抱怨还是在实际尝试编译和运行应用程序时抱怨? Maybe Eclipse doesn't update the project correctly - try one of the following: 也许Eclipse无法正确更新项目-请尝试以下操作之一:

  • have you set your project to 'Build automatically'? 您是否将项目设置为“自动构建”?
  • tried a manual project refresh? 尝试过手动刷新项目? (right click on project / refresh) (右键单击项目/刷新)
  • clean the project via Menu > Project Clean Project... 通过菜单>项目清理项目来清理项目...
  • finally: restart Eclipse 最后:重新启动Eclipse

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM