Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook Login button: apply custom style

i'm facing a strange problem by using new Facebook android sdk 4. With older sdk version i was using:

 <com.facebook.login.widget.LoginButton
    xmlns:fb="http://schemas.android.com/apk/res-auto"
    android:id="@+id/fb_button"
    style="@style/FacebookLoginButton"
    android:layout_width="485dp"
    android:layout_height="64dp"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="-17dp"
    fb:login_text="@string/login_with_facebook"
    fb:logout_text="Logout" />

FacebookLoginButton section of style.xml looks like

<style name="FacebookLoginButton">
    <item name="android:background">@drawable/button_facebook</item>
    <item name="android:textColor">@color/white</item>
    <item name="android:textSize">21sp</item>
    <item name="android:gravity">center</item>
</style>

drawable/button_facebook contains png of a custom button shape. Now whit old version of sdk everithing works well, but with new sdk something gone wrong. i obtain this:

enter image description here

as you can see, theres two facebook icon: the circled one is of facebook button, the second one (the big one) belongs to button_facebook drawable). There's a way to hide the circled icon?

like image 235
giozh Avatar asked Apr 21 '15 12:04

giozh


People also ask

How to design Google Login button?

To create a Google Sign-In button with custom settings, add an element to contain the sign-in button to your sign-in page, write a function that calls signin2. render() with your style and scope settings, and include the https://apis.google.com/js/platform.js script with the query string onload=YOUR_RENDER_FUNCTION .


2 Answers

In the latest Facebook v4 API this is the correct answer:

<com.facebook.login.widget.LoginButton
    xmlns:facebook="http://schemas.android.com/apk/res-auto"
    facebook:com_facebook_login_text="LOGIN"
    facebook:com_facebook_logout_text="LOGOUT"/>
like image 132
Mythul Avatar answered Oct 22 '22 09:10

Mythul


Even i faced the same issue while i was working with fb login.... I fixed the issue by adding the following code....

    fbLoginButton.setBackgroundResource(R.drawable.facebook);
    fbLoginButton.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
    fbLoginButton.setCompoundDrawablePadding(0);
    fbLoginButton.setPadding(0, 0, 0, 0);
    fbLoginButton.setText("");

and here is my xml layout:

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

Hope it helps you.

EDIT 1:
Facebook might change the location of LoginButton class which is present inside its SDK so u might need to change the XML tag accordingly. In my case it was inside com.facebook.widget.LoginButton double check it.

like image 45
Gowtham Raj Avatar answered Oct 22 '22 07:10

Gowtham Raj