Facebook的登录按钮:应用自定义样式 [英] Facebook Login button: apply custom style

查看:3314
本文介绍了Facebook的登录按钮:应用自定义样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在面临一个奇怪的问题,通过使用新的Facebook Android SDK中4。 对于较早的SDK版本我使用:

i'm facing a strange problem by using new Facebook android sdk 4. With older sdk version i was using:

 <com.facebook.login.widget.LoginButton
    xmlns:fb="http://schemas.android.com/apk/res-auto"
    android:id="@+id/fb_button"
    style="@style/FacebookLoginButton"
    android:layout_width="485dp"
    android:layout_height="64dp"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="-17dp"
    fb:login_text="@string/login_with_facebook"
    fb:logout_text="Logout" />

style.xml的FacebookLoginButton部分看起来像

FacebookLoginButton section of style.xml looks like

<style name="FacebookLoginButton">
    <item name="android:background">@drawable/button_facebook</item>
    <item name="android:textColor">@color/white</item>
    <item name="android:textSize">21sp</item>
    <item name="android:gravity">center</item>
</style>

绘制/ button_facebook包含一个自定义按钮形状的PNG。 现在白衣旧版本的SDK everithing的效果很好,但随着新的SDK的东西出了问题。我得到这样的:

drawable/button_facebook contains png of a custom button shape. Now whit old version of sdk everithing works well, but with new sdk something gone wrong. i obtain this:

你可以看到,Theres两根Facebook的图标:圆圈一个是Facebook的按钮,第二个(大个)属于button_facebook绘制)。有一个方法来隐藏的圆圈图标?

as you can see, theres two facebook icon: the circled one is of facebook button, the second one (the big one) belongs to button_facebook drawable). There's a way to hide the circled icon?

推荐答案

即使我面临着同样的问题,而我正与FB登录....我加入下面的code固定的问题....

Even i faced the same issue while i was working with fb login.... I fixed the issue by adding the following code....

    fbLoginButton.setBackgroundResource(R.drawable.facebook);
    fbLoginButton.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
    fbLoginButton.setCompoundDrawablePadding(0);
    fbLoginButton.setPadding(0, 0, 0, 0);
    fbLoginButton.setText("");

和这里是我的XML布局:

and here is my xml layout:

<com.facebook.widget.LoginButton
            xmlns:fb="http://schemas.android.com/apk/res-auto"
            android:id="@+id/fbLoginButton"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            fb:login_text=""
            fb:logout_text=""
            android:scaleType="centerInside" />

希望它可以帮助你。

Hope it helps you.

修改1:
Facebook的可能会改变LoginButton类的位置这是它的SDK里面present所以ü可能需要修改相应的XML标记。在我的情况下,它是在 com.facebook.widget.LoginButton 仔细检查它。

EDIT 1:
Facebook might change the location of LoginButton class which is present inside its SDK so u might need to change the XML tag accordingly. In my case it was inside com.facebook.widget.LoginButton double check it.

这篇关于Facebook的登录按钮:应用自定义样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆