【问题标题】:Custom Button with Facebook SDK 4 (Android)使用 Facebook SDK 4 (Android) 的自定义按钮
【发布时间】:2015-06-11 06:42:11
【问题描述】:

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

提前致谢!

【问题讨论】:

    标签: android facebook button styling


    【解决方案1】:

    你的按钮

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

    【讨论】:

    • 在新的 API com.facebook.widget.LoginButton 似乎被 com.facebook.login.widget.LoginButton 取代
    【解决方案2】:

    对于新的 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"
        ...
    />
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-08-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-02
      • 1970-01-01
      相关资源
      最近更新 更多