Search code examples
androidfacebookfacebook-loginfacebook-android-sdk

How to customize Facebook Login Button in Android


I am having a customize FB sign-in thing needed in my android application. Below is the sample snapshot of the FB Login Button which I want. enter image description here

FacebookLoginXMLFile

<com.facebook.widget.LoginButton
            xmlns:fb="http://schemas.android.com/apk/res-auto"
            android:id="@+id/authButton"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textAlignment = "center"
            android:textColor="#ffffff"
            android:background="@drawable/emailbtn"
            android:drawableLeft="@drawable/facebook_small"
            android:gravity="center_vertical|center_horizontal"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="13dp"
            android:padding="5.75dp"
            android:paddingTop ="4dp"
            android:paddingRight="4dp"
            android:paddingBottom="4dp"
            android:textSize="12sp"
            fb:login_text="@string/signinwithfacebook"
            fb:logout_text="@string/sign_out_from_facebook"
            android:longClickable="false"/>

But I am still getting Facebook's blue color in the background.

PS:I have tried various suggestions from SO itself and none of them work for me


Solution

  • you can use this xml for customize. Replace button with your customized button.

    <FrameLayout
            android:id="@+id/FrameLayout1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >
    
            <com.facebook.login.widget.LoginButton
                android:id="@+id/login_button"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:visibility="gone" />
    
            <Button
                android:id="@+id/fb"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:background="#416BC1"
                android:onClick="onClick"
                android:text="FaceBook"
                android:textColor="#ffffff"
                android:textStyle="bold" />
        </FrameLayout>
    Form more information check my answer,it is full step by step code for facebook login button customization. Check this