Android 如何自定义com.facebook.widget.LoginButton的ui

Android 如何自定义com.facebook.widget.LoginButton的ui,android,facebook,android-layout,android-widget,Android,Facebook,Android Layout,Android Widget,我按照本教程()实现了facebook登录,尽管它可以相应地登录和检索我的电子邮件,但我想实现一个自定义登录图标 这是我登录xml的尝试 <com.facebook.widget.LoginButton android:id="@+id/authButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:

我按照本教程()实现了facebook登录,尽管它可以相应地登录和检索我的电子邮件,但我想实现一个自定义登录图标

这是我登录xml的尝试

   <com.facebook.widget.LoginButton
        android:id="@+id/authButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="30dp"
        android:src="@drawable/ic_launcher" />

谢谢

不久前我自己做了这件事,这是您需要更改的背景资源,但是通过XML做这件事是行不通的,因为它是在构造函数中硬编码的

您应该扩展LoginButton类并创建两个参数构造函数,如下所示

  public LoginButton(Context context, AttributeSet attrs) {
     super(context, attrs);
     this.setBackgroundResource(R.drawable.my_own_drawable);
     this.setCompoundDrawablesWithIntrinsicBounds(R.drawable.my_own_icon, 0, 0, 0);
  }

谢谢你的帮助。你介意再看看这个facebook sdk问题吗?谢谢
  public LoginButton(Context context, AttributeSet attrs) {
     super(context, attrs);
     this.setBackgroundResource(R.drawable.my_own_drawable);
     this.setCompoundDrawablesWithIntrinsicBounds(R.drawable.my_own_icon, 0, 0, 0);
  }