如何为Android添加红色Google+登录按钮?(不是白色的)

Dul*_*ttu 2 authentication android google-plus-signin google-signin

我正在关注https://developers.google.com/identity/sign-in/android/sign-in,将google plus登录添加到我的Android应用中.

本文档建议采用以下方式添加红色Google plus登录按钮.

GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestScopes(new Scope(Scopes.PLUS_LOGIN))
            .requestEmail()
            .build();

SignInButton signInButton = (SignInButton) findViewById(R.id.sign_in_button);
signInButton.setSize(SignInButton.SIZE_STANDARD);
signInButton.setScopes(gso.getScopeArray());
Run Code Online (Sandbox Code Playgroud)

但问题是现在不推荐使用setScopes方法.(https://developers.google.com/android/reference/com/google/android/gms/common/SignInButton)

setScopes(Scope[] scopes)
This method was deprecated. Setting scopes will no longer impact the branding.
Run Code Online (Sandbox Code Playgroud)

我也试过以下方法.

mGoogleApiClient = new GoogleApiClient.Builder(this)
            .enableAutoManage(this , this)
            .addScope(new Scope(Scopes.PLUS_LOGIN))
            .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
            .build();
Run Code Online (Sandbox Code Playgroud)

但红色的Google+按钮没有出现.如何添加以下按钮呢?

在此输入图像描述

BNK*_*BNK 8

如果您阅读Plus API弃用说明,最后会找到以下注释:

随着Google+ People API的弃用,我们还更改了 品牌指南.所有登录按钮都应标记为"Google登录",背景为蓝色白色.

在此输入图像描述

  • 非常感谢您详细而明确的答案. (2认同)