在Facebook Android SDK 4.0中设置按钮的登录/注销文本? [英] Set Login/Logout Text for Button in Facebook Android SDK 4.0?
本文介绍了在Facebook Android SDK 4.0中设置按钮的登录/注销文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的xml看起来像这样
My xml looks like this
<com.facebook.login.widget.LoginButton xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fb_login_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:text="CONNECT WITH FACEBOOK"
android:textColor="@color/white"
android:textSize="20sp"
android:textStyle="bold"
android:background="@drawable/button_fb_login"/>
和背景drawble xml是
and background drawble xml is
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape>
<solid android:color="#4e69a2" />
<stroke android:width="3dip" android:color="#4e69a2" />
<padding android:bottom="0dip" android:left="0dip" android:right="0dip" android:top="0dip" />
</shape>
</item>
<item>
<shape>
<solid android:color="#3b5998" />
<stroke android:width="3dip" android:color="#3b5998" />
<padding android:bottom="0dip" android:left="0dip" android:right="0dip" android:top="0dip" />
</shape>
</item>
现在在android studio预览屏幕它显示为预期。
Now in android studio preview screen it shows as expected.
但是当我在手机或模拟器上运行它时,默认情况下显示登录FACEBOOK,如下所示
But when I run it on my phone or emulator, it shows "LOG IN WITH FACEBOOK" by default, like this
我在运行应用程序时获取我的自定义文本吗?
How do I get my custom text on running the application?
推荐答案
使用 facebook:login_text
和 :logout_text
<com.facebook.widget.LoginButton
android:id="@+id/login_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
facebook:confirm_logout="false"
facebook:fetch_user_info="true"
android:text="testing 123"
facebook:login_text="LOGIN"
facebook:logout_text="LOGOUT"
/>
如果上述无效,请尝试在您的值文件夹中添加以下内容
If the above doesnt work, try to add following in your values folder
<resources>
<string name="com_facebook_loginview_log_in_button">LOGIN</string>
<string name="com_facebook_loginview_log_out_button">LOGOUT</string>
</resources>
更新:可能的原因
更新2:可能的解决方案
覆盖字符串中的这些字符串.xml
<string name="com_facebook_loginview_log_out_button">Log out</string>
<string name="com_facebook_loginview_log_in_button">Log in</string>
<string name="com_facebook_loginview_log_in_button_long">Log in with Facebook</string>
可以找到其他字符串这里
这篇关于在Facebook Android SDK 4.0中设置按钮的登录/注销文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文