Search code examples
androidfacebookbuttonstyling

Custom Button with Facebook SDK 4 (Android)


I'm trying to customize the login button in Facebook SDK 4.0 (Android) but no way... I was looking in Fb Docs but no results. Any idea please ?

Thanks in advance!


Solution

  • Your Button

    <com.facebook.widget.LoginButton
        xmlns:fb="http://schemas.android.com/apk/res-auto"
        android:id="@+id/login_button"
        android:layout_width="249dp"
        android:layout_height="45dp"
        android:layout_above="@+id/textView1"
        android:layout_centerHorizontal="true"
        android:layout_gravity="center_horizontal"
        android:layout_marginBottom="30dp"
        android:layout_marginTop="30dp"
        android:contentDescription="@string/login_desc"
        android:scaleType="centerInside"
        fb:login_text=""
        fb:logout_text="" />
    

    and in your Activity

    LoginButton authbutton = (LoginButton) findViewById(R.id.login_button);
    authbutton.setBackgroundResource(R.drawable.facebook);
    authButton.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0,0);