Mic*_*ael 34 android facebook-android-sdk
Facebook Android sdk有一个 com.facebook.widget.LoginButton
我想将自己的图像放入"登录"按钮.可能吗 ?
到目前为止,我已经尝试添加android:src="@drawable/facebook"布局文件作为按钮元素的属性,没有运气
Mic*_*ael 78
我最终将文本覆盖为空字符串,然后将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="" />
Run Code Online (Sandbox Code Playgroud)
在代码中我定义了后台资源:
final LoginButton button = (LoginButton) findViewById(R.id.login_button);
button.setBackgroundResource(R.drawable.facebook);
Run Code Online (Sandbox Code Playgroud)
有点解决方法,但我更喜欢改变Facebook SDK代码(虽然它也非常直接),并担心每次更新其版本时都要更新.
小智 10
是的,如果你想更改文本和图像,然后写下面的代码.
authButton = (LoginButton) view.findViewById(R.id.authButton);
authButton.setBackgroundResource(R.drawable.icon);
authButton.setText("Login");
authButton.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);`
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
36215 次 |
| 最近记录: |