我正在将facebook SDK 3.0集成到我的应用程序中,我已添加facebook登录按钮以进行布局,有人可以帮助我如何使用我的自定义图像更改facebook登录按钮
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFF"
android:id="@+id/main_ui_container">
<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"
/>
<LinearLayout/>
答案 0 :(得分:3)
我是否理解你添加了Facebook自己的自定义FacebookLoginButton视图?
如果是这种情况,那么构造函数FacebookLoginButton(final Context context, final AttributeSet attrs)
将由布局缓冲器调用,它引用了facebook库的R文件 - 没有用。
因此,如果您想要自定义该按钮超出facebook sdk中显示的内容,我已成功将视图类--FacelLoginButton.java复制到我自己的项目中(您可能需要修改FacebookLoginButton.java到确保所有内容都正确引用回到facebook库)。与此同时,将该构造函数引用的所有资源复制到自己的项目中。不言而喻,您现在需要确保复制类中的所有内容现在都引用您的项目资源。
最后,您当然需要将布局文件中的按钮类更改为在您自己的项目中复制的FacebookLoginButton的完全限定类名。
希望这有帮助。
答案 1 :(得分:0)
您应该只能在布局中为LoginButton指定android:background。
请参阅Friend Smash示例,该示例使用LoginButton的自定义背景。
答案 2 :(得分:0)
您可以自定义按钮的这些元素:
<declare-styleable name="com_facebook_login_view">
<attr name="confirm_logout" format="boolean"/>
<attr name="fetch_user_info" format="boolean"/>
<attr name="login_text" format="string"/>
<attr name="logout_text" format="string"/>
</declare-styleable>
在xml中使用这些属性。您还可以定义样式并更改与按钮相关的所有内容。