在Facebook的Android SDK中4.0设置登录/注销文本按钮? [英] Set Login/Logout Text for Button in 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的工作室preVIEW屏状态显示正常。
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
和 Facebook的: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>
更新:可能的原因
<一个href="https://github.com/facebook/facebook-android-sdk/blob/master/facebook/src/com/facebook/login/widget/LoginButton.java#L599">https://github.com/facebook/facebook-android-sdk/blob/master/facebook/src/com/facebook/login/widget/LoginButton.java#L599
更新2:可能的解决方法
覆盖这些字符串在的strings.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>
其他字符串可以发现<一href="https://github.com/facebook/facebook-android-sdk/blob/master/facebook/res/values/strings.xml#L27">here
这篇关于在Facebook的Android SDK中4.0设置登录/注销文本按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!