0

This is my xml file code :-

 <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/White">
       <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp"
            android:gravity="center"
            android:text="Login with FACEBOOK"
            android:textSize="22sp"
            android:textColor="@color/White"
            android:layout_centerVertical="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:drawableLeft="@drawable/facebooklogo"/>
    </RelativeLayout>

This is java file :

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;

public class LoginActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
       }
}

LOGCAT :-

FATAL EXCEPTION: main

java.lang.RuntimeException: Unable to start activity ComponentInfo{aavid.rks.blablacar/aavid.rks.blablacar.LoginActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class Button

Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class Button at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)

Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f020047 a=-1 r=0x7f020047}at android.content.res.Resources.loadDrawable(Resources.java:2063)

8
  • have you missed the button's closing tag in copy/paste or in your code too?? Commented Feb 20, 2016 at 6:15
  • check facebooklogo in your drawable folder Commented Feb 20, 2016 at 6:16
  • I forget .. still issue is there. its not issue my mistake.. Commented Feb 20, 2016 at 6:16
  • 1
    try edit name to facebooklogo.png Commented Feb 20, 2016 at 6:21
  • 1
    oh yah its works...convert name into facebooklogo.png instead of facebooklogo.png(v21).. works Commented Feb 20, 2016 at 6:23

2 Answers 2

1

Do check your facebooklogo size. Also make sure you keep all the resources names lower cased, That causes the issue of xml parser. In your case

@color/White

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

1 Comment

resource identifiers, everything must be lower case, so an uppercase Color wouldn't work, even if the resource you were trying to access existed in the appropriate namespace.
0

change your code....you have incomplete xml

 <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/White">
       <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp"
            android:gravity="center"
            android:text="Login with FACEBOOK"
            android:textSize="22sp"
            android:textColor="@color/White"
            android:layout_centerVertical="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:drawableLeft="@drawable/facebooklogo" />
    </RelativeLayout>

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.