Android的布局错误:"资源ID< RES_ID>是字体样式(而不是ATTR)QUOT的不是;样式、布局、而不是、字体

2023-09-04 03:26:39 作者:24K·纯性感

我看到我瓦特/ Android的这$ P $的呈现在Eclipse pventing我的一些布局文件之前从来没有见过一个错误。他们渲染罚款运行。

这显示在图形布局编辑器(和我的错误日志)的错误是: 种源ID 0x1010081的类型风格(而不是attr​​)使用的不是

我在我的R上的文件搜索资源ID 0x1010081,我无法找到它,所以我猜,也许不知何故,我有一个内置的Andr​​oid ATTR冲突。我也验证了我所有的样式属性下面点实际的风格,而不是ATTR。任何帮助AP preciated。

下面是我的完整布局code:

 < RelativeLayout的的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    的xmlns:工具=htt​​p://schemas.android.com/tool​​s
    机器人:layout_width =match_parent
    机器人:layout_height =match_parent
    机器人:背景=@可绘制/ bkg_light
    机器人:填充=@扪/ padding_med>

    < RelativeLayout的
        机器人:ID =@ + ID / relativeLayout_activity
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =@扪/ button_height
        机器人:背景=@可绘制/ xml_button
        机器人:填充=@扪/ padding_med>

        <的TextView
            风格=@风格/ text_large_bold_white
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_alignParentLeft =真
            机器人:layout_centerVertical =真
            机器人:文本=@字符串/活动/>

        <的TextView
            机器人:ID =@ + ID / textView_activity
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_centerVertical =真
            机器人:layout_marginRight =@扪/ margin_med
            机器人:layout_toLeftOf =@ + ID / textView_arrow_right_start_date
            机器人:文本=@字符串/ none_selected/>

        <的TextView
            机器人:ID =@ + ID / textView_arrow_right_start_date
            风格=@风格/ arrow_right
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_alignParentRight =真
            机器人:layout_centerVertical =真/>
    < / RelativeLayout的>

    <! -  KV时间 - >

    < RelativeLayout的
        机器人:ID =@ + ID / relativeLayout_duration
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_below =@ + ID / relativeLayout_activity
        机器人:layout_marginTop =@扪/ margin_large
        机器人:背景=@可绘制/ xml_button>

        <的TextView
            机器人:ID =@ + ID / textView_duration
            风格=@风格/ text_large_bold_white
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:layout_alignParentLeft =真
            机器人:layout_centerVertical =真
            机器人:文本=@字符串/ duration_lc
            机器人:以下属性来=@扪/ padding_med/>

        <微调
            机器人:ID =@ + ID / spinner_duration
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =@扪/ button_height
            机器人:layout_alignParentRight =真
            机器人:项=@阵列/ array_durations
            机器人:提示=@字符串/ duration_lc
            机器人:spinnerMode =下拉列表中
            机器人:可点击=FALSE/>
    < / RelativeLayout的>

< / RelativeLayout的>
 
应用崩溃了 Android vitals 帮您精确诊断

这是我的styles.xml:

 < XML版本=1.0编码=UTF-8&GT?;
<资源>
    <样式名称=arrow_right>
        <项目名称=机器人:TEXTSTYLE>大胆< /项目>
        <项目名称=机器人:TEXTSIZE> @扪/ text_xxlarge< /项目>
        <项目名称=机器人:文字> @字符串/ arrow_right< /项目>
    < /风格>

    <样式名称=button_blue>
        <项目名称=机器人:TEXTSTYLE>大胆< /项目>
        <项目名称=机器人:文字颜色> @色/白< /项目>
        <项目名称=机器人:背景> @可绘制/ selector_button_blue< /项目>
        <项目名称=机器人:填充> @扪/ padding_med< /项目>
    < /风格>

    <样式名称=button_blue_small>
        <项目名称=机器人:TEXTSTYLE>大胆< /项目>
        <项目名称=机器人:文字颜色> @色/白< /项目>
        <项目名称=机器人:背景> @可绘制/ selector_button_blue_small< /项目>
        <项目名称=机器人:填充> @扪/ padding_med< /项目>
    < /风格>

    <样式名称=button_dark>
        <项目名称=机器人:TEXTSTYLE>大胆< /项目>
        <项目名称=机器人:文字颜色> @色/白< /项目>
        <项目名称=机器人:背景> @可绘制/ selector_button_dark< /项目>
        <项目名称=机器人:填充> @扪/ padding_med< /项目>
    < /风格>

    <样式名称=button_light>
        <项目名称=机器人:TEXTSTYLE>大胆< /项目>
        <项目名称=机器人:文字颜色> @彩色/黑白LT; /项目>
        <项目名称=机器人:背景> @可绘制/ selector_button_light< /项目>
        <项目名称=机器人:填充> @扪/ padding_med< /项目>
    < /风格>

    <样式名称=button_light_small>
        <项目名称=机器人:TEXTSTYLE>大胆< /项目>
        <项目名称=机器人:文字颜色> @彩色/黑白LT; /项目>
        <项目名称=机器人:TEXTSIZE> @扪/ text_small< /项目>
        <项目名称=机器人:背景> @可绘制/ selector_button_light< /项目>
        <项目名称=机器人:填充> @扪/ padding_small< /项目>
    < /风格>

    <样式名称=text_small_gray_light>
        <项目名称=机器人:TEXTSIZE> @扪/ text_small< /项目>
        <项目名称=机器人:文字颜色> @色/ gray_light< /项目>
    < /风格>

    <样式名称=text_med_bold_gray_light>
        <项目名称=机器人:TEXTSTYLE>大胆< /项目>
        <项目名称=机器人:TEXTSIZE> @扪/ text_med< /项目>
        <项目名称=机器人:文字颜色> @色/ gray_light< /项目>
    < /风格>

    <样式名称=text_large_bold_white>
        <项目名称=机器人:TEXTSTYLE>大胆< /项目>
        <项目名称=机器人:TEXTSIZE> @扪/ text_large< /项目>
    < /风格>

    <样式名称=text_large_bold_black>
        <项目名称=机器人:TEXTSTYLE>大胆< /项目>
        <项目名称=机器人:TEXTSIZE> @扪/ text_large< /项目>
        <项目名称=机器人:文字颜色> @彩色/黑白LT; /项目>
    < /风格>

    <样式名称=text_large_bold_gray_dark>
        <项目名称=机器人:TEXTSTYLE>大胆< /项目>
        <项目名称=机器人:TEXTSIZE> @扪/ text_large< /项目>
        <项目名称=机器人:文字颜色> @色/ gray_dark< /项目>
    < /风格>

    <样式名称=text_large_bold_gray_light>
        <项目名称=机器人:TEXTSTYLE>大胆< /项目>
        <项目名称=机器人:TEXTSIZE> @扪/ text_large< /项目>
        <项目名称=机器人:文字颜色> @色/ gray_light< /项目>
    < /风格>

    <样式名称=text_large_bold_white>
        <项目名称=机器人:TEXTSTYLE>大胆< /项目>
        <项目名称=机器人:TEXTSIZE> @扪/ text_large< /项目>
        <项目名称=机器人:文字颜色> @色/白< /项目>
    < /风格>

    <样式名称=text_large_white>
        <项目名称=机器人:TEXTSIZE> @扪/ text_large< /项目>
        <项目名称=机器人:文字颜色> @色/白< /项目>
    < /风格>
< /资源>
 

下面是我的自定义theme.xml:

 < XML版本=1.0编码=UTF-8&GT?;
<资源的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android>
    <样式名称=Theme.P90X父=@风格/ Theme.Sherlock>
        <项目名称=机器人:文字颜色>#FFFFFFFF< /项目>
    < /风格>
< /资源>
 

解决方案

我也有这个问题,用同样的资源ID显示出来。它消失了,当我改变安卓spinnerMode 对话框中的所以我怀疑这是不是你的$ C $的问题℃。

在讨论的ID指的是Android的属性 spinnerStyle 。查看文档的 R.attr

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

安卓spinnerMode =下拉列表中

安卓spinnerStyle =@安卓风格/ Widget.Spinner.DropDown

I'm seeing an error I've never seen before w/ Android that's preventing some of my layout files from rendering in Eclipse. They render fine at runtime.

The error that shows up in the graphical layout editor (and my Error log) is: "Resouce id 0x1010081 is not of type STYLE (instead attr)"

I've searched for resource id 0x1010081 in my R files, and I can't find it so I'm guessing maybe somehow I have a conflict with a built in Android attr. I've also verified that all of my style attributes below point to actual styles and not attr. Any help appreciated.

Here's my full layout code:

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

And here's 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>

And here's my custom 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>

解决方案

I also have this problem, with the same resource ID showing up. It disappears when I change android:spinnerMode to "dialog" so I suspect it's not a problem with your code.

The id in question refers to the android attribute spinnerStyle. See the doc for R.attr

I found a workaround, namely replace

android:spinnerMode="dropdown"

with

android:spinnerStyle="@android:style/Widget.Spinner.DropDown".