background image of android screen

2

Good afternoon!    I'm trying to put a background image of the login screen of my application, this image was downloaded from the unsplash website, and when I put it in the background property of my layout the following error is displayed:

        java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ramattecgmail.rafah.herdeirosapp/com.ramattecgmail.rafah.herdeirosapp.Activitys.LoginActivity}: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class <unknown>

follows XML code:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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:background="@drawable/bg"
tools:context="com.ramattecgmail.rafah.herdeirosapp.Activitys.LoginActivity">

   <Button
    android:id="@+id/bt_login_face"
    android:layout_width="@dimen/bt_login_width"
    android:layout_height="@dimen/bt_login_height"
    android:paddingTop="@dimen/bt_login_pad_vertical"
    android:paddingBottom="@dimen/bt_login_pad_vertical"
    android:paddingLeft="@dimen/bt_login_pad_horizontal"
    android:layout_marginBottom="@dimen/bt_login_face_mrg_bot"
    android:layout_gravity="center_horizontal|bottom"
    android:stateListAnimator="@null"
    android:elevation="12dp"
    android:background="@drawable/face_button_login"
    android:drawableLeft="@drawable/face_btn2"
    android:text="@string/login_face"
    android:textSize="@dimen/bt_login_txts"
    android:textAlignment="center"
    android:textColor="@color/primaryTextColor" />

<Button
    android:id="@+id/bt_login_google"
    android:layout_width="@dimen/bt_login_width"
    android:layout_height="@dimen/bt_login_height"
    android:paddingLeft="@dimen/bt_login_pad_horizontal"
    android:paddingBottom="@dimen/bt_login_pad_vertical"
    android:paddingTop="@dimen/bt_login_pad_vertical"
    android:layout_marginBottom="@dimen/bt_login_google_mrg_bot"
    android:layout_gravity="center_horizontal|bottom"
    android:stateListAnimator="@null"
    android:elevation="12dp"
    android:background="@drawable/google_button_login"
    android:drawableLeft="@drawable/google_btn"
    android:text="@string/login_google"
    android:textSize="@dimen/bt_login_txts"
    android:textAlignment="center"
    android:textColor="@color/red" />

 </FrameLayout>

Below is the activity code:

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

    mAuth = FirebaseAuth.getInstance();

    /*************** TESTE DE LOGIN COM BOTÃO CUSTOMIZADO ***********/
    FacebookSdk.sdkInitialize(getApplicationContext());

    btFaceLogin = findViewById(R.id.bt_login_face);
    btGoogleLogin = findViewById(R.id.bt_login_google);

    //EVENTOS
    btGoogleLogin.setOnClickListener(this);
    btFaceLogin.setOnClickListener(this);

    callbackManager = CallbackManager.Factory.create();
    LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
        @Override
        public void onSuccess(LoginResult loginResult) {
            Log.d(TAG, "Sucesso linha 82");
            AccessToken token  = AccessToken.getCurrentAccessToken();
            handleFacebookAccessToken(token);
        }

        @Override
        public void onCancel() {

        }

        @Override
        public void onError(FacebookException error) {

        }
    });

    /*************** TESTE DE LOGIN COM BOTÃO CUSTOMIZADO ***********/

    // Configure sign-in to request the user's ID, email address, and basic
    // profile. ID and basic profile are included in DEFAULT_SIGN_IN.
    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestIdToken(getString(R.string.default_web_client_id))
            .requestEmail()
            .build();

    // Build a GoogleApiClient with access to the Google Sign-In API and the
    // options specified by gso.
    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */)
            .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
            .build();

}

In the setConentView the error is already displayed, the image is in png format. By running the app this way it does not even open.

    
asked by anonymous 17.05.2018 / 22:36

2 answers

0

This error usually occurs when your android:background is too large. Take the image down test.

    
18.05.2018 / 02:52
-1

Try to put this in your xml:

<Button
   android:id="@+id/bt_login_face"
   android:layout_width="wrap_content"
   android:layout_height="@dimen/bt_login_height" />
    
17.05.2018 / 22:54