Search code examples
androidfacebook-loginfacebook-android-sdk

Android - How to change the text on Facebook login button


I'm trying to change the text on Facebook login button on Android.

I have gone through number of Stack Overflow answers but none them worked. Is there a way to change it?

I have tried the answers in these links: [1][1], [2][2], [3][3].

If I use com.facebook.login.widget.LoginButton button, I'm unable change the text on the button. (I'm able to login though)

<com.facebook.login.widget.LoginButton
    android:id="@+id/fragment_login_fb_login_button"
    android:layout_width="@dimen/fragment_login_fb_button_width"
    android:layout_height="@dimen/fragment_login_fb_button_height"
    android:layout_gravity="center"
    android:layout_marginTop="@dimen/fragment_login_fb_button_top_margin"
    android:background="@drawable/fragment_login_fb_login_button_background"
    android:drawableLeft="@drawable/facebook_icon"
    android:gravity="center"
    android:text="@string/label_fragment_login_sign_in_with_facebook"
    android:textColor="@android:color/white"
    android:textStyle="bold"/>

If I use Button I was able to change the text, but I'm unable to login.

<Button
    android:id="@+id/fragment_login_fb_login_button"
    android:layout_width="@dimen/fragment_login_fb_button_width"
    android:layout_height="@dimen/fragment_login_fb_button_height"
    android:layout_gravity="center"
    android:layout_marginTop="@dimen/fragment_login_fb_button_top_margin"
    android:background="@drawable/fragment_login_fb_login_button_background"
    android:drawableLeft="@drawable/facebook_icon"
    android:gravity="center"
    android:text="@string/label_fragment_login_sign_in_with_facebook"
    android:textColor="@android:color/white"
    android:textStyle="bold"/>

I'm using android facebook sdk version 4.5.0 [1]: customize Android Facebook Login button [2]: Is it possible to change Facebook login button image in Facebook Android SDK3? [3]: Set Login/Logout Text for Button in Facebook Android SDK 4.0?


Solution

  • You can try to use facebook namespace and set com_facebook_login_textattribute for it

    <com.facebook.login.widget.LoginButton
            xmlns:facebook="http://schemas.android.com/apk/res-auto"
            facebook:com_facebook_login_text="YourText"/>