簡體   English   中英

Android Google plus 注銷按鈕看起來與 Google 教程文檔中的登錄按鈕不同

[英]Android Google plus Sign out button looks different from sign in button in Google tutorial docs

我正在按照 Google 開發者網站中提到的步驟在我的應用中實現登錄和退出。

上面提到的添加登錄和退出按鈕的代碼是:

<!-- sign-in button -->
<com.google.android.gms.common.SignInButton
    android:id="@+id/sign_in_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

<!-- sign-out button -->
<Button
    android:id="@+id/sign_out_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Sign Out"
    android:visibility="gone" />

在那邊提到的示例中,退出按鈕看起來與退出按鈕非常不同(而且很奇怪)。

這是因為退出按鈕不是從com.google.android.gms嗎?

com中是否有適當的注銷按鈕? google.android.gms ?

谷歌沒有提供退出按鈕。

如果您想要與 google 風格相同的額外按鈕,您需要自己創建它們。

但這比聽起來容易得多,Google 提供了許多資源來向您展示如何創建一個看起來像 Google 按鈕的按鈕。 看看這里:

https://developers.google.com/+/branding-guidelines

這是我在 Microsoft Paint 中制作的一個小示例,向您展示您可以制作的東西!

在此處輸入圖片說明

您可以使您的按鈕看起來與<com.google.android.gms.common.SignInButton>相同,使用 xml 標記style向您的按鈕添加預定義style

style="@style/FirebaseUI.Button.AccountChooser.GoogleButton"

請注意,它是 FirebaseUI 樣式,您可以放置​​所需的 Button 文本。

怎么樣:將文本登錄更改為注銷。

布局文件

<com.google.android.gms.common.SignInButton
android:id="@+id/sign_out_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

kotlin.kt

val signOutButton: SignInButton = findViewById(R.id.sign_out_button)
signOutButton.setSize(SignInButton.SIZE_STANDARD)
signOutButton.setOnClickListener { signOut() }
val txtLogout = signOutButton.getChildAt(0) as TextView
try {
    txtLogout.setText("Sign out")
} catch (e: Exception) {
    //e.printStackTrace()
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM