Android 如何定制Google plus登录按钮

Android 如何定制Google plus登录按钮,android,Android,我已经尝试了很多,但无法自定义Google plus登录按钮。 请帮帮我 谢谢首先,在layout.xml添加您的按钮: <com.google.android.gms.common.SignInButton android:id="@+id/sign_in_button" android:layout_width="wrap_content" android:layout_height="wrap_content" /> 并使用此代码对应用程序说“等待登录”按钮: /*

我已经尝试了很多,但无法自定义Google plus登录按钮。 请帮帮我


谢谢

首先,在layout.xml添加您的按钮:

<com.google.android.gms.common.SignInButton
android:id="@+id/sign_in_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
并使用此代码对应用程序说“等待登录”按钮:

    /* Track whether the sign-in button has been clicked so that we know to resolve
 * all issues preventing sign-in without waiting.
 */
private boolean mSignInClicked;

/* Store the connection result from onConnectionFailed callbacks so that we can
 * resolve them when the user clicks sign-in.
 */
private ConnectionResult mConnectionResult;

/* A helper method to resolve the current ConnectionResult error. */
private void resolveSignInError() {
  if (mConnectionResult.hasResolution()) {
    try {
      mIntentInProgress = true;
      startIntentSenderForResult(mConnectionResult.getIntentSender(),
          RC_SIGN_IN, null, 0, 0, 0);
    } catch (SendIntentException e) {
      // The intent was canceled before it was sent.  Return to the default
      // state and attempt to connect to get an updated ConnectionResult.
      mIntentInProgress = false;
      mGoogleApiClient.connect();
    }
  }
}

public void onConnectionFailed(ConnectionResult result) {
  if (!mIntentInProgress) {
    // Store the ConnectionResult so that we can use it later when the user clicks
    // 'sign-in'.
    mConnectionResult = result;

    if (mSignInClicked) {
      // The user has already clicked 'sign-in' so we attempt to resolve all
      // errors until the user is signed in, or they cancel.
      resolveSignInError();
    }
  }
}
并使用此onclick代码(指示是否为登录按钮):

使用此代码指示您是否已登录:

    protected void onActivityResult(int requestCode, int responseCode, Intent intent) {
  if (requestCode == RC_SIGN_IN) {
    if (responseCode != RESULT_OK) {
      mSignInClicked = false;
    }

    mIntentInProgress == false;

    if (!mGoogleApiClient.isConnecting()) {
      mGoogleApiClient.connect();
    }
  }
}
并在成功登录时添加消息:

    @Override
public void onConnected(Bundle connectionHint) {
  mSignInClicked = false;
  Toast.makeText(this, "User is connected!", Toast.LENGTH_LONG).show();
}
另外,请阅读以下内容:

如果您更改了此项,则这是违反策略的行为。
    protected void onActivityResult(int requestCode, int responseCode, Intent intent) {
  if (requestCode == RC_SIGN_IN) {
    if (responseCode != RESULT_OK) {
      mSignInClicked = false;
    }

    mIntentInProgress == false;

    if (!mGoogleApiClient.isConnecting()) {
      mGoogleApiClient.connect();
    }
  }
}
    @Override
public void onConnected(Bundle connectionHint) {
  mSignInClicked = false;
  Toast.makeText(this, "User is connected!", Toast.LENGTH_LONG).show();
}