13

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?

Pavel Chuchuva
  • 22,633
  • 10
  • 99
  • 115
VK.N
  • 193
  • 1
  • 2
  • 12

4 Answers4

55

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"/>
random
  • 10,238
  • 8
  • 57
  • 101
  • 2
    It works fine. for for the login logout custom text try this- ` xmlns:facebook="http://schemas.android.com/apk/res-auto" facebook:com_facebook_login_text="YourText" facebook:com_facebook_logout_text="Your Logout text" ` – Mahmudur Rahman Apr 03 '16 at 07:42
  • 3
    Its works fine but not on preview of android studio But working good on device – Khizar Hayat Aug 03 '16 at 09:58
0

Please check the license agreement and you will see that you are not allowed to change it. Also you are not allowed to change the "f". The only things that you are allowed by the license is to use different standard colors. See 7.3 in fb and the brand allowed assets

danysz
  • 580
  • 3
  • 11
  • thanks for the update, but it does not say specifically like "you cannot change the text on login button", Your answer helped me to use facebook sdk login button – VK.N Sep 20 '15 at 17:23
  • from my personal experience it can go fine but they can just find it in a day and you are just out until you fixit...and they don't care how many active users do you have. they just shut you down. PS. personal experience, and if it help maybe you can set it as an answer.hanks – danysz Sep 21 '15 at 07:07
0

Its a trick not a proper method.

  • Create a Relative layout.
  • Define your facebook_botton.
  • Also define your custom design button.
  • Overlap them.
<RelativeLayout android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal"
    android:layout_marginTop="30dp">
    <com.facebook.login.widget.LoginButton
    xmlns:facebook="http://schemas.android.com/apk/res-auto"
    android:id="@+id/login_button"
    android:layout_width="300dp"
    android:layout_height="100dp"
    android:paddingTop="15dp"
    android:paddingBottom="15dp" />
    <LinearLayout
    android:id="@+id/llfbSignup"
    android:layout_width="300dp"
    android:layout_height="50dp"
    android:background="@drawable/facebook"
    android:layout_gravity="center_horizontal"
    android:orientation="horizontal">
    <ImageView
    android:layout_width="30dp"
    android:layout_height="30dp"
    android:src="@drawable/facbk"
    android:layout_gravity="center_vertical"
    android:layout_marginLeft="10dp" />
    <View
    android:layout_width="1dp"
    android:layout_height="match_parent"
    android:background="@color/fullGray"
    android:layout_marginLeft="10dp"/>
    <com.yadav.bookedup.fonts.GoutamBold
    android:layout_width="240dp"
    android:layout_height="50dp"
    android:text="Sign Up via Facebook"
    android:gravity="center"
    android:textColor="@color/white"
    android:textSize="18dp"
    android:layout_gravity="center_vertical"
    android:layout_marginLeft="10dp"/>
    </LinearLayout>
</RelativeLayout>
AMIT YADAV
  • 11
  • 4
0

Run on device not working in preview

       <com.facebook.login.widget.LoginButton
        android:layout_height="wrap_content"
        android:id="@+id/signup_signupFacebookButton"
        android:layout_width="fill_parent"
        xmlns:facebook="http://schemas.android.com/apk/res-auto"
        facebook:com_facebook_login_text="Sign up with Facebook"/>
Syed Danish Haider
  • 1,334
  • 11
  • 15