Binary XML file <line 20>: Error inflating class <Unknown>
        Posted  
        
            by 
                user2750644
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by user2750644
        
        
        
        Published on 2014-06-07T09:13:25Z
        Indexed on 
            2014/06/07
            9:24 UTC
        
        
        Read the original article
        Hit count: 654
        
 
 
<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:layout_gravity="top|left|right"
android:background="@drawable/bg"
tools:context=".MainActivity" >
<ImageView
    android:id="@+id/imageView1"
    android:layout_width="wrap_content"
    android:layout_height="50dp"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:src="@drawable/top_red_bar"
    android:layout_alignParentLeft="true"
    android:paddingLeft="0dp"
    android:scaleType="centerCrop" />
<ImageView
    android:id="@+id/imageView2"
    android:layout_width="wrap_content"
    android:layout_height="45dp"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_alignTop="@+id/imageView1"
    android:layout_centerHorizontal="true"
    android:src="@drawable/job_bar" />
<ImageView
    android:id="@+id/imageView3"
    android:layout_width="238dp"
    android:layout_height="50dp"
    android:layout_below="@+id/imageView1"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:layout_marginTop="123dp"
    android:src="@drawable/button" 
    android:alpha="0.85"
    android:onClick="myhandler"/>
<ImageView
    android:id="@+id/imageView4"
    android:layout_width="wrap_content"
    android:layout_height="50dp"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/imageView3"
    android:layout_marginTop="24dp"
    android:src="@drawable/button" 
    android:alpha="0.85"/>
<ImageView
    android:id="@+id/imageView5"
    android:layout_width="35dp"
    android:layout_height="45dp"
    android:layout_above="@+id/imageView4"
    android:layout_alignLeft="@+id/imageView3"
    android:layout_marginLeft="21dp"
    android:src="@drawable/employer" />
<ImageView
    android:id="@+id/imageView6"
    android:layout_width="50dp"
    android:layout_height="50dp"
    android:layout_alignLeft="@+id/imageView5"
    android:layout_alignTop="@+id/imageView4"
    android:src="@drawable/jobseekers" />
<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignTop="@+id/imageView5"
    android:layout_centerHorizontal="true"
    android:layout_marginLeft="18dp"
    android:layout_toRightOf="@+id/imageView6"
    android:text="Employer"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:textColor="#ffffff"
    android:textStyle="bold" />
<TextView
    android:id="@+id/textView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView1"
    android:layout_alignTop="@+id/imageView4"
    android:text="Job Seekers"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:textColor="#ffffff"
    android:textStyle="bold" />
</RelativeLayout>
My app gets crashed with error statement Binary XML file <line 20>: Error inflating class <Unknown>.
Why does this happen?? Could anyone fix this? And interestingly, when I remove all code except background, it works!!!  
© Stack Overflow or respective owner