Android布局错误:";资源id<;资源id>;不是类型样式(而是attr)";

Android布局错误:";资源id<;资源id>;不是类型样式(而是attr)";,android,android-layout,layout,resources,android-resources,Android,Android Layout,Layout,Resources,Android Resources,我看到了一个我以前从未见过的错误,它阻止了我的一些布局文件在Eclipse中呈现。它们在运行时渲染良好 图形布局编辑器(以及我的错误日志)中显示的错误为: “资源id 0x1010081不是类型样式(而是属性)” 我在我的R文件中搜索了资源id 0x1010081,但找不到它,所以我猜我可能与内置的Android attr有冲突。我还验证了下面的所有样式属性都指向实际样式,而不是attr。谢谢你的帮助 以下是我的完整布局代码: <RelativeLayout xmlns:android="

我看到了一个我以前从未见过的错误,它阻止了我的一些布局文件在Eclipse中呈现。它们在运行时渲染良好

图形布局编辑器(以及我的错误日志)中显示的错误为: “资源id 0x1010081不是类型样式(而是属性)”

我在我的R文件中搜索了资源id 0x1010081,但找不到它,所以我猜我可能与内置的Android attr有冲突。我还验证了下面的所有样式属性都指向实际样式,而不是attr。谢谢你的帮助

以下是我的完整布局代码:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/bkg_light"
    android:padding="@dimen/padding_med" >

    <RelativeLayout
        android:id="@+id/relativeLayout_activity"
        android:layout_width="fill_parent"
        android:layout_height="@dimen/button_height"
        android:background="@drawable/xml_button"
        android:padding="@dimen/padding_med" >

        <TextView            
            style="@style/text_large_bold_white"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_centerVertical="true"
            android:text="@string/activity" />

        <TextView
            android:id="@+id/textView_activity"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:layout_marginRight="@dimen/margin_med"
            android:layout_toLeftOf="@+id/textView_arrow_right_start_date" 
            android:text="@string/none_selected"/>

        <TextView
            android:id="@+id/textView_arrow_right_start_date"
            style="@style/arrow_right"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_centerVertical="true" />
    </RelativeLayout>

    <!-- kv Duration -->

    <RelativeLayout
        android:id="@+id/relativeLayout_duration"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/relativeLayout_activity"
        android:layout_marginTop="@dimen/margin_large"
        android:background="@drawable/xml_button">

        <TextView
            android:id="@+id/textView_duration"
            style="@style/text_large_bold_white"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_centerVertical="true"
            android:text="@string/duration_lc" 
            android:paddingLeft="@dimen/padding_med"/>

        <Spinner
            android:id="@+id/spinner_duration"
            android:layout_width="wrap_content"
            android:layout_height="@dimen/button_height"
            android:layout_alignParentRight="true"
            android:entries="@array/array_durations"
            android:prompt="@string/duration_lc"
            android:spinnerMode="dropdown" 
            android:clickable="false"/>
    </RelativeLayout>

</RelativeLayout>

下面是my styles.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="arrow_right">
        <item name="android:textStyle">bold</item>
        <item name="android:textSize">@dimen/text_xxlarge</item>
        <item name="android:text">@string/arrow_right</item>
    </style>

    <style name="button_blue">
        <item name="android:textStyle">bold</item>
        <item name="android:textColor">@color/white</item>
        <item name="android:background">@drawable/selector_button_blue</item>
        <item name="android:padding">@dimen/padding_med</item>
    </style>

    <style name="button_blue_small">
        <item name="android:textStyle">bold</item>
        <item name="android:textColor">@color/white</item>
        <item name="android:background">@drawable/selector_button_blue_small</item>
        <item name="android:padding">@dimen/padding_med</item>
    </style>

    <style name="button_dark">
        <item name="android:textStyle">bold</item>
        <item name="android:textColor">@color/white</item>
        <item name="android:background">@drawable/selector_button_dark</item>
        <item name="android:padding">@dimen/padding_med</item>
    </style>

    <style name="button_light">
        <item name="android:textStyle">bold</item>
        <item name="android:textColor">@color/black</item>
        <item name="android:background">@drawable/selector_button_light</item>
        <item name="android:padding">@dimen/padding_med</item>
    </style>

    <style name="button_light_small">
        <item name="android:textStyle">bold</item>
        <item name="android:textColor">@color/black</item>
        <item name="android:textSize">@dimen/text_small</item>
        <item name="android:background">@drawable/selector_button_light</item>
        <item name="android:padding">@dimen/padding_small</item>
    </style>  

    <style name="text_small_gray_light">
        <item name="android:textSize">@dimen/text_small</item>
        <item name="android:textColor">@color/gray_light</item>
    </style>

    <style name="text_med_bold_gray_light">
        <item name="android:textStyle">bold</item>
        <item name="android:textSize">@dimen/text_med</item>
        <item name="android:textColor">@color/gray_light</item>
    </style>    

    <style name="text_large_bold_white">
        <item name="android:textStyle">bold</item>
        <item name="android:textSize">@dimen/text_large</item>
    </style>

    <style name="text_large_bold_black">
        <item name="android:textStyle">bold</item>
        <item name="android:textSize">@dimen/text_large</item>
        <item name="android:textColor">@color/black</item>
    </style>

    <style name="text_large_bold_gray_dark">
        <item name="android:textStyle">bold</item>
        <item name="android:textSize">@dimen/text_large</item>
        <item name="android:textColor">@color/gray_dark</item>
    </style>

    <style name="text_large_bold_gray_light">
        <item name="android:textStyle">bold</item>
        <item name="android:textSize">@dimen/text_large</item>
        <item name="android:textColor">@color/gray_light</item>
    </style>

    <style name="text_large_bold_white">
        <item name="android:textStyle">bold</item>
        <item name="android:textSize">@dimen/text_large</item>
        <item name="android:textColor">@color/white</item>
    </style>

    <style name="text_large_white">
        <item name="android:textSize">@dimen/text_large</item>
        <item name="android:textColor">@color/white</item>
    </style>
</resources>

大胆的
@尺寸/文字大小
@字符串/向右箭头
大胆的
@颜色/白色
@可拖动/选择器按钮\蓝色
@尺寸/填充尺寸
大胆的
@颜色/白色
@可拉拔/选择器按钮蓝色小
@尺寸/填充尺寸
大胆的
@颜色/白色
@可拉拔/选择器按钮\u暗
@尺寸/填充尺寸
大胆的
@颜色/黑色
@可牵引/选择器按钮灯
@尺寸/填充尺寸
大胆的
@颜色/黑色
@尺寸/文字大小
@可牵引/选择器按钮灯
@尺寸/填充尺寸
@尺寸/文字大小
@彩色/灰光
大胆的
@尺寸/文字尺寸
@彩色/灰光
大胆的
@尺寸/文本大小
大胆的
@尺寸/文本大小
@颜色/黑色
大胆的
@尺寸/文本大小
@颜色/灰色/深色
大胆的
@尺寸/文本大小
@彩色/灰光
大胆的
@尺寸/文本大小
@颜色/白色
@尺寸/文本大小
@颜色/白色
下面是我的自定义theme.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
    <style name="Theme.P90X" parent="@style/Theme.Sherlock">
        <item name="android:textColor">#ffffffff</item>
    </style>
</resources>

#ffffffff

您是否尝试过将“每个样式”属性更改为以下内容:

style="?attr/text_large_bold_white"

删除所有
style
元素,然后逐个添加它们,并始终检查其是否仍然呈现。因此,您至少可以找出是谁的错。

我也有这个问题,出现了相同的资源ID。当我将android:spinnerMode更改为dialog时,它会消失,所以我怀疑这不是您的代码的问题

问题中的id指的是android属性
spinnerStyle
。有关详细信息,请参阅文档

我找到了一个解决办法,即替换

android:spinnerMode=“dropdown”


android:spinnerStyle=“@android:style/Widget.Spinner.DropDown”

由于此错误,为了子孙后代,谷歌指向此页面

在我的例子中,我一时兴起,关闭并重新打开了eclipse,错误消失了,eclipse在呈现预览时没有问题

虽然我坚信这可能不是所有人的情况


我想,如果您觉得自己做的一切都是对的,那么重启eclipse不会有什么坏处。

正如朱利安西姆斯所说,问题是

android:spinnerMode="dropdown"
他的解决方案(替换为android:spinnerStyle=“@android:style/Widget.Spinner.DropDown”)在我的手机上运行,但在我的平板电脑上不运行

我的解决方案更简单:删除行


spinnerMode=“dropdown”
默认为,因此没有必要

您可以附上完整的错误日志和您的styles.xml吗?@JustinJasmann:styles.xml列出。我唯一得到的是上面列出的样式。为什么你不接受正确的答案?我布局中的样式是在styles.xml中定义的自定义样式。我已经在帖子中列出了这一点。我尝试删除所有样式标记,但仍然看到错误,可能与系统样式存在冲突?您是否有自定义主题,可能会间接添加样式?我有一个自定义主题,其父级为Theme.Sherlock。然而,这很简单。我已将其添加到帖子中。当您完全删除自定义主题时,您能尝试一下错误是否仍然存在吗?没有帮助,没有影响。这非常有效。非常感谢。OP应该相信你的答案是正确的。注意@android:style/Widget.Spinner.DropDown需要API级别11,虽然它也为我消除了错误,但在运行时我得到了“错误膨胀类android.Widget.Spinner”。但是它的抛出:
04-19 15:55:44.161:E/AndroidRuntime(8799):java.lang.RuntimeException:无法启动活动组件信息:android.view.InflateException:二进制XML文件行#14:对类android.widget.Spinner进行膨胀时出错
我将min SDK设置为15,但仍然得到“二进制XML文件行#14:对类android.widget.Spinner进行膨胀时出错”