我的 xml 看起来像这样
<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是
<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 预览屏幕中,它按预期显示。
但是当我在手机或模拟器上运行它时,它默认显示“LOG IN WITH FACEBOOK”,像这样
如何在运行应用程序时获取自定义文本?
最佳答案
只需要相应地更改属性。引用:this
例如:
<com.facebook.login.widget.LoginButton
xmlns:facebook="http://schemas.android.com/apk/res-auto"
facebook:com_facebook_login_text="LOGIN"/>
关于android - 在 Facebook Android SDK 4.0 中为按钮设置登录/注销文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29740325/