【问题标题】:Theme preview fails in EclipseEclipse 中的主题预览失败
【发布时间】:2012-04-24 15:32:56
【问题描述】:

我创建了一个简单的用户名/密码对话框,我想在其中应用一个主题(它基本上定义了windowBackground),并且还想在Eclipse 中预览。

我看到我的主题在主题组合框中与其他主题一起显示,但选择它会产生以下错误:

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)

主题定义:

<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>

调试工作正常。不过所见即所得会更显眼。

【问题讨论】:

标签: android android-theme


【解决方案1】:

首先在编辑器中关闭您的布局文件,然后重新启动您的 Eclipse。

【讨论】:

  • 您应该从图形布局视图的顶部选择列表中选择正确的自定义主题。
  • 请注意,如果出现 eclipse 错误(标记正常),仅重新启动本身并没有帮助,但您必须在重新启动之前 关闭 xml 文件日食(就像 Sibevin Wang 说的那样)。
  • 这也适用于 AS。需要先关闭布局xml文件。
  • 我的 xml 没有任何错误,我的样式是正确的。重启后就好了
【解决方案2】:

我也遇到了这个问题。 我通过改变主题解决了它。 执行此操作的步骤

  1. 在“图形布局”中打开活动
  2. 单击下拉列表 AppTheme(在活动“图形布局”的顶部栏上)
  3. 选择项目主题->AppBaseTheme

【讨论】:

    【解决方案3】:

    您应该在图形布局中选择另一个主题(例如:默认主题)。我认为您的自定义主题不支持某些属性。

    【讨论】:

      【解决方案4】:

      确保以不同值显示的所有其他styles.xml 包含您的自定义主题部分。

      我有类似的问题。 就我而言,我在 res 下的 values-large 文件夹中添加了一个自定义主题。它在运行时工作,但在 Eclipse 中给出错误。 所以我尝试在所有其他 styles.xml 文件中添加自定义部分(在我的情况下,styles.xml 文件中总共添加了 3 个标签)。即values-normal-hdpivalues-normal-mdpivaluse-v11values-v14下的styles.xml文件...

      然后砰!它解决了我浪费了一整天的问题。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2015-01-14
        • 2010-09-07
        • 1970-01-01
        • 1970-01-01
        • 2017-06-04
        • 2018-10-31
        • 1970-01-01
        相关资源
        最近更新 更多