2016-11-12 43 views
2

我正在關注https://developers.google.com/identity/sign-in/android/sign-in,將google plus登錄添加到我的android應用中。如何爲Android添加紅色的Google+登錄按鈕? (不是白色的)

本文檔建議採用以下方式添加紅色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()); 

但問題是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. 

我也試過下面的方法。

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

但是沒有出現紅色的Google+按鈕。那麼如何添加下面的按鈕?

enter image description here

回答

4

如果你讀Plus API Deprecation Notes創建自定義按鈕,你會發現在結束了以下注釋:

隨着Google+的人API的棄用,我們也改變了我們的 branding guidelines。所有登錄按鈕應標記爲「Google 登錄」,其中藍色白色背景。

enter image description here

+1

非常感謝您的詳細和明確的答案。 –

0

在僅播放服務-8.1.0,谷歌更新的按鈕顏色和樣式後Google+的紅色按鈕。因此,使用以下步驟

Customize your sign-in button

+0

您所提供的鏈接沒有解釋如何創建紅色谷歌加按鈕登錄。你能告訴我該怎麼做嗎? –

相關問題