android - 是否可以在 Facebook Android SDK3 中更改 Facebook 登录按钮图像?

标签 android facebook-android-sdk

Facebook Android sdk 有一个 com.facebook.widget.LoginButton

我想为登录按钮添加自己的图像。有可能吗?

到目前为止,我已经尝试将 android:src="@drawable/facebook" 作为按钮元素的属性添加到布局文件中,但没有成功

最佳答案

我最终将文本覆盖为空字符串,然后将按钮的 setBackgroundResource 定义为我的图像(不需要动态登录/注销文本功能)

<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);

一种解决方法,但我更喜欢这种方法而不是更改 Facebook SDK 代码(尽管它也非常简单),并且每次更新他们的版本时都会担心更新。

关于android - 是否可以在 Facebook Android SDK3 中更改 Facebook 登录按钮图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16496738/

相关文章:

android - 从隐式 Intent 中获取数据

android - RxJava2 : Filtering a List<Object> in an Observable

android - 获取我 friend 的所有 facebook ids/name

java - 发布不带元数据的 Picasa 网络相册照片(结果 403 禁止)

android - 在新的 whatsapp ver 2.11.399 (android) 上为图像添加标题

android - Mac OS 上的 Phonegap eclipse 环境

android - com.facebook.Settings.publishInstallAsync 是否适用于 Android < 3.0

android - 登录 facebook android 时授权对话框出现两次

java - 没有 fragment 的Facebook android sdk登录按钮

android - Facebook SDK 3.0 - 附加权限