在Facebook的Andr​​oid SDK中3.5自定义Facebook登录按钮图像自定义、按钮、图像、Andr

2023-09-05 00:10:12 作者:装酷的笑容傻货的大脑

在一个类似的静脉this queston 适用于以下至Facebook的Andr​​oid SDK 3.0 ...

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

是否有可能使用自己的形象在SDK 3.5 Facebook的登录按钮,无需定制的SDK本身?

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

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

我看到两个图像与新SDK。我的图像(R.drawable.facebook)是一家大型的灰色背景与白色的F。但是,我也看到了小白色的背景和透明的F由叠加在背景之上的原Facebook的按钮图标的到来。请参见 Facebook的文档相关的SDK 3.5日志按钮。我想彻底删除原来的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.

推荐答案

除了设置背景资源,也呼吁:

In addition to setting the background resource, also call:

button.setCompoundDrawablesWithIntrinsicBounds(0,0,0,0);