是否有可能改变Facebook的登录按钮图像中的Facebook的Android SDK3? [英] Is it possible to change Facebook login button image in Facebook Android SDK3?
问题描述
Facebook的Android SDK中有一个 com.facebook.widget.LoginButton
Facebook Android sdk has a com.facebook.widget.LoginButton
我想把我自己的形象的登录按钮。这可能吗?
I want to put my own image for the Login button. Is it possible ?
到目前为止,我已经试图加入机器人:SRC =@可绘制/ Facebook的
来布局文件作为属性按钮元素,没有运气。
So far i've tried adding android:src="@drawable/facebook"
to the layout file as an attribute to the button element with no luck
推荐答案
我结束了覆盖文本为空字符串,然后定义 setBackgroundResource
按钮我图像(不需要动态登录/登出文字的功能)
I ended up overriding the text to be empty string and then defining the setBackgroundResource
of the button to my image (didn't need the dynamic login/logout text functionality)
<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="" />
而在code我定义的背景资源:
And in code I defined the background resource :
final LoginButton button = (LoginButton) findViewById(R.id.login_button);
button.setBackgroundResource(R.drawable.facebook);
样的解决办法,但我preferred这种过度变化的Facebook SDK code(虽然它是非常简单的为好),并担心更新,每次我更新了自己的版本。
Kind of a workaround, but I preferred this over changing Facebook SDK code (although it's very straight forward as well) and worry about updating each time I update the their version.
这篇关于是否有可能改变Facebook的登录按钮图像中的Facebook的Android SDK3?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!