Android layout error: "Resource id <res_id> is not of type STYLE (instead attr)"

11,642

Solution 1

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

Solution 2

Have you tried changing the each style property to something like this:

style="?attr/text_large_bold_white"

Solution 3

As JulianSymes says the problem is

android:spinnerMode="dropdown"

His solution (replace for android:spinnerStyle="@android:style/Widget.Spinner.DropDown") runs on my phone but not on my tablet

My solution is more simple: DELETE THE LINE.

spinnerMode="dropdown" is by default, therefore it's unnecesary

Share:
11,642

Related videos on Youtube

Karim Varela
Author by

Karim Varela

Technology executive, investor, and advisor with a career history of producing highly scalable digital consumer products. Exceptional record of success in building and leading top performing, global engineering teams, managing budgets as large as $5MM, and bringing order and agility to growing engineering teams. Excels at implementing agile engineering practices, building product-focused engineering teams, and delivering software on time. Outstanding problem solving, leadership, and team motivation skills. —————— Core skills —————— Transformational Leadership: Carried out agile restructurings and process improvements which have resulted in massive improvements to engineering productivity. Platform Migration: Carried out multiple platform and database migrations resulting in cost-savings, improved operational efficiency, and better system performance. Global Workforce Management: Supervised as many as 25 people, across distributed teams in the US, Mexico, Argentina, Dominican Republic, Poland, Ukraine, London, India, and The Netherlands. Scaling Products Globally: Played key roles in localizing and distributing mobile apps and services to key international markets, growing user bases to tens of millions of users. System Architecture: Architected and built multiple secure and performant systems from the ground up to handle workloads in social, banking, and travel. —————— Specific Skills —————— Process Optimization Strategy, Planning, &amp; Execution Engineering Operations Budget &amp; Cost Control Product Management Lean &amp; Agile Methodologies Cloud Architecture Microservices ETL Web Services Relational Databases NoSQL Databases Coaching &amp; Mentoring Machine Learning

Updated on June 15, 2022

Comments

  • Karim Varela
    Karim Varela almost 2 years

    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>
    
    • Justin Jasmann
      Justin Jasmann about 11 years
      Could you attach the full error log and your styles.xml?
    • Karim Varela
      Karim Varela about 11 years
      @JustinJasmann: styles.xml listed. The only I get is the one listed above.
    • John
      John over 9 years
      Why didn't you accept the right answer ?
  • Karim Varela
    Karim Varela about 11 years
    The styles in my layout are custom styles defined in styles.xml. I've listed that in the posting.
  • Karim Varela
    Karim Varela about 11 years
    I tried removing all style tags and I'm still seeing the error Maybe there's some conflict with a system style?
  • Ridcully
    Ridcully about 11 years
    Do you have a custom Theme perhaps, which would add styles indirectly?
  • Karim Varela
    Karim Varela about 11 years
    I do have a custom theme whose parent is Theme.Sherlock. It's pretty simple, however. I've added it to the posting.
  • Ridcully
    Ridcully about 11 years
    Can you try wether the error is still there when you remove your custom theme altogether?
  • Karim Varela
    Karim Varela about 11 years
    Didn't help, made no difference.
  • pmont
    pmont over 10 years
    This works perfectly. Thank you! OP should credit yours as the correct answer.
  • Sofi Software LLC
    Sofi Software LLC over 10 years
    Note @android:style/Widget.Spinner.DropDown requires API level 11
  • Patrick
    Patrick about 10 years
    While it does get rid of the error for me as well, I get "Error inflating class android.widget.Spinner" at runtime.
  • Pratik Butani
    Pratik Butani about 10 years
    But its throwing: 04-19 15:55:44.161: E/AndroidRuntime(8799): java.lang.RuntimeException: Unable to start activity ComponentInfo: android.view.InflateException: Binary XML file line #14: Error inflating class android.widget.Spinner
  • JulianSymes
    JulianSymes about 10 years
    @PratikButani in view of the number of upvotes to my answer, this is likely a separate issue, or your minimum SDK level is set to something less than 11.
  • gswierczynski
    gswierczynski almost 10 years
    I got min SDK set to 15 and I still get "Binary XML file line #14: Error inflating class android.widget.Spinner"
  • Brian White
    Brian White over 9 years
    To those getting the InflateException, note that the attribute name also changes from spinnerMode to spinnerStyle.