Facebook Android SDK 3.5中自定义Facebook登录按钮图片

17

此问题有类似的想法,涉及到Facebook Android SDK 3.0...

在SDK 3.5中是否可以使用自己的图像作为Facebook登录按钮,而不需要自定义SDK本身?

使用链接问题中提供的答案:

<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”的大灰色背景。 但是,我还看到来自原始Facebook按钮图标的小白色背景和透明的“f”覆盖在背景上。 请参阅与SDK 3.5登录按钮相关的Facebook文档。 我想完全删除原始的Facebook图标。

1个回答

30

除了设置背景资源之外,还需调用:

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

谢谢Ming Li,它工作得很好 :) - Android Dev

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接