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/