Search code examples
androidandroid-facebook

customize Android Facebook Login button


I want to customize the look of the Facebook login button which we get along with the Facebook sdk for android (facebook-android-sdk-3.0.1). I want a simple android button which has title "Login via Facebook". I could not find any documentation regarding that.

So if any one knows on how to do it in a simple way, please tell me or direct me on how to do it.


Solution

  • You can use styles for modifiy the login button like this

    <style name="FacebookLoginButton">
        <item name="android:textSize">@dimen/smallTxtSize</item>
        <item name="android:background">@drawable/facebook_signin_btn</item>
        <item name="android:layout_marginTop">10dp</item>
        <item name="android:layout_marginBottom">10dp</item>
        <item name="android:layout_gravity">center_horizontal</item>
    </style>
    

    and in layout

    <com.facebook.widget.LoginButton
            xmlns:fb="http://schemas.android.com/apk/res-auto"
            android:id="@+id/loginFacebookButton"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            fb:login_text="@string/loginFacebookButton"
            fb:logout_text=""
            style="@style/FacebookLoginButton"/>