android - how to change the text on facebook login button

VK.N picture VK.N · Sep 20, 2015 · Viewed 14.9k times · Source

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

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

I have tried the answers in these links: 1, 2, 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

Answer

random picture random · Sep 20, 2015

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"/>