Set Login/Logout Text for Button in Facebook Android SDK 4.0?

Devanshu Dwivedi picture Devanshu Dwivedi · Apr 20, 2015 · Viewed 18.2k times · Source

My xml looks like this

<com.facebook.login.widget.LoginButton xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fb_login_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:text="CONNECT WITH FACEBOOK"
android:textColor="@color/white"
android:textSize="20sp"
android:textStyle="bold"
android:background="@drawable/button_fb_login"/>

and background drawble xml is

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
    <shape>
        <solid android:color="#4e69a2" />
        <stroke android:width="3dip" android:color="#4e69a2" />
        <padding android:bottom="0dip" android:left="0dip" android:right="0dip" android:top="0dip" />
    </shape>
</item>

<item>
    <shape>
        <solid android:color="#3b5998" />
        <stroke android:width="3dip" android:color="#3b5998" />
        <padding android:bottom="0dip" android:left="0dip" android:right="0dip" android:top="0dip" />
    </shape>
</item>

Now in android studio preview screen it shows as expected.

enter image description here

But when I run it on my phone or emulator, it shows "LOG IN WITH FACEBOOK" by default, like this

enter image description here

How do I get my custom text on running the application?

Answer

Mark KWH picture Mark KWH · May 6, 2015

Just need change the attribute accordingly. Refer to : this

eg:

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