Android Eclipse 中的主题预览失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10301171/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Theme preview fails in Eclipse
提问by usr-local-ΕΨΗΕΛΩΝ
I have made a simple username/password dialog to which I want to apply a theme (it basically defines windowBackground
) and would also like to preview in Eclipse
.
我制作了一个简单的用户名/密码对话框,我想在其中应用一个主题(它基本上定义了windowBackground
),并且还想在Eclipse
.
I see that my theme is displayed along other themes in the Theme combo box, but selecting it produces the following error:
我看到我的主题与主题组合框中的其他主题一起显示,但选择它会产生以下错误:
Missing styles. Is the correct theme chosen for this layout?
Use the Theme combo box above the layout to choose a different layout, or fix the theme style references.
Failed to find style 'textViewStyle' in current theme
android.content.res.Resources$NotFoundException
Couldn't find theme resource attr/textAppearanceLarge for the current theme
Exception details are logged in Window > Show View > Error Log
The following classes could not be found:
- TextView (Change to android.widget.TextView, Fix Build Path, Edit XML)
Theme definition:
主题定义:
<style name="my_theme">
<item name="android:windowBackground">@drawable/form_header</item>
<!-- <item name="android:padding">0dp</item>-->
<item name="android:windowNoTitle">true</item>
</style>
Debugging works fine. However WYSIWYG would be more appreciable.
调试工作正常。然而,WYSIWYG 会更可观。
回答by Sibevin Wang
Close your layout files in the editor firstand restart your Eclipse.
闭上你的布局文件编辑器中的第一个,并重新启动您的Eclipse。
回答by Tawtin Tom
I also got this problem. I solved it by changing theme. Steps to do this
我也遇到了这个问题。我通过改变主题解决了它。执行此操作的步骤
- Open activity in "Graphic Layout"
- Click drop down list AppTheme (On top bar of activity "Graphic Layout")
- Select Project Themes->AppBaseTheme
- 在“图形布局”中打开活动
- 单击下拉列表 AppTheme(在活动“图形布局”的顶部栏上)
- 选择项目主题->AppBaseTheme
回答by duongvanthai
You should choose another theme in Graphic Layout (ex: default theme). I think your custom theme not support some attribute.
您应该在图形布局中选择另一个主题(例如:默认主题)。我认为您的自定义主题不支持某些属性。
回答by Shirish Herwade
Make sure your all other styles.xml present under different values contains your custom theme part.
确保在不同值下存在的所有其他 style.xml 包含您的自定义主题部分。
I had similar problem.
In my case I had added a custom theme in values-large folder under res. And it was working at runtime but giving error as yours in eclipse.
So i tried adding the custom part(in my case totally there was 3 tags added to styles.xml file) in all other styles.xml file. i.e. styles.xml files under values-normal-hdpi
, values-normal-mdpi
, valuse-v11
and values-v14
...
我有类似的问题。就我而言,我在 res 下的 values-large 文件夹中添加了一个自定义主题。它在运行时工作,但在 eclipse 中给出错误。所以我尝试在所有其他 style.xml 文件中添加自定义部分(在我的例子中总共有 3 个标签添加到 style.xml 文件中)。即values-normal-hdpi
,values-normal-mdpi
、valuse-v11
和values-v14
...下的styles.xml 文件
And BOOM!!! It solved my problem which wasted my whole day.
和繁荣!!!它解决了我浪费我一整天的问题。