android - 如何在 Android 中自定义 Facebook 登录按钮

标签 android facebook facebook-login facebook-android-sdk

我的 Android 应用程序需要自定义 FB 登录。 下面是我想要的 FB 登录按钮的示例快照。 enter image description here

FacebookLoginXMLFile

<com.facebook.widget.LoginButton
            xmlns:fb="http://schemas.android.com/apk/res-auto"
            android:id="@+id/authButton"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textAlignment = "center"
            android:textColor="#ffffff"
            android:background="@drawable/emailbtn"
            android:drawableLeft="@drawable/facebook_small"
            android:gravity="center_vertical|center_horizontal"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="13dp"
            android:padding="5.75dp"
            android:paddingTop ="4dp"
            android:paddingRight="4dp"
            android:paddingBottom="4dp"
            android:textSize="12sp"
            fb:login_text="@string/signinwithfacebook"
            fb:logout_text="@string/sign_out_from_facebook"
            android:longClickable="false"/>

但我仍然在背景中看到 Facebook 的蓝色。

PS:我尝试了SO本身的各种建议,但没有一个对我有用

最佳答案

您可以使用此 xml 进行自定义。将按钮替换为您的自定义按钮。

<FrameLayout
        android:id="@+id/FrameLayout1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <com.facebook.login.widget.LoginButton
            android:id="@+id/login_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:visibility="gone" />

        <Button
            android:id="@+id/fb"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="#416BC1"
            android:onClick="onClick"
            android:text="FaceBook"
            android:textColor="#ffffff"
            android:textStyle="bold" />
    </FrameLayout>
形成更多信息检查我的答案,它是 Facebook 登录按钮定制的完整分步代码。 Check this

关于android - 如何在 Android 中自定义 Facebook 登录按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31266791/

相关文章:

安卓 4.2 : back stack behaviour with nested fragments

java - 更改密码 Activity

java - recyclerview 项目显示抽屉导航 fragment 中显示空白屏幕

javascript - Facebook Canvas,无法在移动设备上从 Facebook 登录

javascript - FB.XFBML.parse 未捕获 [对象对象]

ios - 我可以在 iOS 应用程序和相应的 Facebook 游戏之间共享相同的 App id 和 App Secret 吗?

ios - 此应用目前无法使用 Facebook 登录

android - 如何在共享首选项中存储切换按钮状态并稍后在 android 中加载状态?

Facebook/{object-id}/likes - 错误#803 "Some of the aliases you requested do not exist"

ios - 通过应用程序进行 Azure B2C Facebook 注册