简体   繁体   English

Android Google plus 注销按钮看起来与 Google 教程文档中的登录按钮不同

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

I am following the steps mentioned in Google developers site to implement sign in and sign out in my app.我正在按照 Google 开发者网站中提到的步骤在我的应用中实现登录和退出。

The code to add the sign-in and sign-out button as mentioned there is:上面提到的添加登录和退出按钮的代码是:

<!-- 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" />

In the sample mentioned over there, the sign out button looks very different(and odd) from the sign out button.在那边提到的示例中,退出按钮看起来与退出按钮非常不同(而且很奇怪)。

Is this because the sign out button is not taken from com.google.android.gms ?这是因为退出按钮不是从com.google.android.gms吗?

Is there a proper sign-out button available in com. com中是否有适当的注销按钮? google.android.gms ? google.android.gms ?

There is no sign-out button provided by google.谷歌没有提供退出按钮。

If you would like extra buttons in the same style as google's, you will need to create them yourself.如果您想要与 google 风格相同的额外按钮,您需要自己创建它们。

But it's a lot easier than it sounds, there are many resources provided by Google to show you how to create a button that looks just like a Google button.但这比听起来容易得多,Google 提供了许多资源来向您展示如何创建一个看起来像 Google 按钮的按钮。 Take a look over here:看看这里:

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

Here is a little example I made in microsoft paint to show you the kind of stuff you can make!这是我在 Microsoft Paint 中制作的一个小示例,向您展示您可以制作的东西!

在此处输入图片说明

You can make your button look the same as <com.google.android.gms.common.SignInButton> , adding a predefined style to your button with the xml tag style :您可以使您的按钮看起来与<com.google.android.gms.common.SignInButton>相同,使用 xml 标记style向您的按钮添加预定义style

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

Note that its a FirebaseUI style and you can put the Button text that you want.请注意,它是 FirebaseUI 样式,您可以放置​​所需的 Button 文本。

How about : change text Sign in to Sign out.怎么样:将文本登录更改为注销。

layout.xml布局文件

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

kotlin.kt 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