Skip to content

java.lang.UnsupportedOperationException: Can't convert to color: type=0x2 #5

@vishsha9

Description

@vishsha9

Hi,

First off, great work with this library. Looks absolutely gorgeous.
I was using it and suddenly in the last few days I got the same error as the one here:
#4

It works if I make my own selector_toolbar_button but putting exact colors such as this:

my_selector_toolbar_button:

<?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
        <item android:state_pressed="true">
            <shape android:shape="rectangle">
                <solid android:color="#009688" />
            </shape>
        </item>

        <item android:state_focused="true">
            <shape android:shape="rectangle">
                <solid android:color="#009688" />
            </shape>
        </item>

        <item>
            <shape android:shape="rectangle">
                <solid android:color="#009688" />
            </shape>
        </item>
    </selector>

However if I use this, then the outcome is not as expected. The rectangle button color does not take up the whole button height, and the button in the toolbar appears before the FAB button disappears.

Here's the xml file where I'm using this button:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context="com.vishalshah.pricetrack.ProductDetailsActivity">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/app_bar"
        android:layout_width="match_parent"
        android:layout_height="150dp"
        android:fitsSystemWindows="true"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/toolbar_layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:contentScrim="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_collapseMode="pin"
                app:popupTheme="@style/AppTheme.PopupOverlay" />

        </android.support.design.widget.CollapsingToolbarLayout>
    </android.support.design.widget.AppBarLayout>

    <include layout="@layout/content_product_details" />


    <am.gaut.android.toolbarbutton.ToolbarButton
        android:id="@+id/btn_toolbar_buy"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        style="?attr/borderlessButtonStyle"
        android:background="@drawable/selector_toolbar_button"
        android:textAppearance="@style/TextAppearance.AppCompat.Widget.Button.Inverse"
        android:paddingLeft="@dimen/toolbar_button_padding"
        android:paddingRight="@dimen/toolbar_button_padding"
        android:drawablePadding="@dimen/toolbar_button_padding"
        android:text="Buy"
        android:drawableLeft="@drawable/ic_shopping_cart_24dp"
        android:fadingEdgeLength="30dp"
        app:layout_anchor="@id/app_bar"
        app:layout_anchorGravity="right|end"
        android:onClick="openURL"/>

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="@dimen/fab_margin"
        android:src="@drawable/ic_shopping_cart_24dp"
        app:layout_anchor="@id/app_bar"
        app:layout_anchorGravity="bottom|end"
        android:onClick="openURL"/>

</android.support.design.widget.CoordinatorLayout>

I've also tried removing the
android:drawableLeft="@drawable/ic_shopping_cart_24dp"

As the stackoverflow post you linked to the other issue said it might be an out of memory exception where the image used might have a higher resolution.

Any idea what might be the issue? And just to state again, this has happened recently when I have not made any changes to this part of the code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions