繁体   English   中英

带有 Facebook SDK 4 的自定义按钮 (Android)

[英]Custom Button with Facebook SDK 4 (Android)

我正在尝试自定义 Facebook SDK 4.0 (Android) 中的登录按钮,但没有办法......我在 Fb Docs 中查找但没有结果。 有什么想法吗?

提前致谢!

你的按钮

<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="" />

并在您的活动中

LoginButton authbutton = (LoginButton) findViewById(R.id.login_button);
authbutton.setBackgroundResource(R.drawable.facebook);
authButton.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0,0);

对于新的Facebook SDK (4+),您可以使用此代码来自定义您的按钮文本

<com.facebook.login.widget.LoginButton
    xmlns:facebook="http://schemas.android.com/apk/res-auto"
    facebook:com_facebook_login_text="Custom Login text"
    ...
/>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM