Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom Facebook login button image in Facebook Android SDK 3.5

In a similar vein to this queston related to Facebook Android SDK 3.0 ...

Is it possible to use my own image for the Facebook login button in SDK 3.5, without customising the SDK itself?

Using the answer given in the linked question:

<com.facebook.widget.LoginButton
    xmlns:fb="http://schemas.android.com/apk/res-auto"
    android:id="@+id/login_button"
    android:layout_width="249dp"
    android:layout_height="45dp"
    android:layout_above="@+id/textView1"
    android:layout_centerHorizontal="true"
    android:layout_gravity="center_horizontal"
    android:layout_marginBottom="30dp"
    android:layout_marginTop="30dp"
    android:contentDescription="@string/login_desc"
    android:scaleType="centerInside"
    fb:login_text=""
    fb:logout_text="" />

and:

final LoginButton button = (LoginButton) findViewById(R.id.login_button);
button.setBackgroundResource(R.drawable.facebook);

I am seeing two images with the new SDK. My image (R.drawable.facebook) is a large grey background with a white "f". However, I am also seeing the small white background and transparent "f" coming from the original facebook button icon overlayed on top of the background. See the facebook docs related to the SDK 3.5 log in button. I want to remove the original facebook icon completely.

like image 560
Jon G Avatar asked Sep 18 '13 09:09

Jon G


1 Answers

In addition to setting the background resource, also call:

button.setCompoundDrawablesWithIntrinsicBounds(0,0,0,0);
like image 121
Ming Li Avatar answered Sep 28 '22 17:09

Ming Li



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!