0

I'm trying to add custom buttons to my XML I have a linear layout and a RelativeLayout inside.

When i use android:background="@drawable/WHATEVER" it works. But when I add the @drawable, it crashes with the Binary XML file line #44: Error inflating class <unknown> Exception.

The problem is only for the RelativeLayout buttons.

The XML file:

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" 
    android:gravity="center_vertical">
    <Button
        android:id="@+id/blue_button"
        android:layout_width="75dp"
        android:layout_height="75dp"
        android:background="@color/blue" 
        android:onClick="checkSeqence"/>
    <Button
        android:id="@+id/changing_colors"
        android:layout_width="75dp"
        android:layout_height="75dp"
        android:background="@color/black"
        android:layout_centerInParent="true"
        android:clickable="false"
        />
    <Button
        android:id="@+id/yellow_button"
        android:layout_width="75dp"
        android:layout_height="75dp"
        android:layout_alignParentRight="true"
        android:background="@drawable/custom_button_yellow" 
        android:onClick="checkSeqence"/>

</RelativeLayout>   
 <Button
   android:id="@+id/green_button"
   android:layout_width="75dp"
   android:layout_height="75dp"
   android:layout_marginTop="120dp"
   android:background="@drawable/custom_button_green" 
   android:onClick="checkSeqence"/>
</LinearLayout>        

How can i use the drawable?

3
  • On which line are you seeing this error? Commented Oct 13, 2012 at 12:45
  • The problem is in the drawable XML, not this XML. Commented Oct 13, 2012 at 12:46
  • I accidentally started animation-list XML instead of layer-list. Got it after you told me that the problem is in the drawable. Thanks. Commented Oct 13, 2012 at 13:04

1 Answer 1

1

I accidentally started animation-list XML instead of layer-list. Changing it to layer-list solved the problem

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.