Android Studio:未显示Google登录按钮

问题描述 投票:0回答:1

我正在关注有关如何在我的Android应用中实现Google身份验证的教程。我已经达到了在我的activity_login.xml文件中添加google预定义按钮的阶段,就像它的解释here

  <com.google.android.gms.common.SignInButton
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:text="Login"
        android:layout_marginLeft="50dp"
        android:layout_marginRight="50dp"
        android:layout_marginBottom="50dp"/> 

但是,在预览中什么也没有出现,除了line之外,按钮应该是:enter image description here这是教程中的屏幕截图,用于解释其显示方式:enter image description here

我已按照本教程中的说明认真地执行了每个步骤,所以我真的不明白为什么这不起作用。主要是,我已经在依赖项中将它们添加到app / build.gradle中:

implementation 'com.google.firebase:firebase-analytics:17.2.0' //Added for google authentication
implementation 'com.google.firebase:firebase-auth:19.2.0' //Added for google authentication
implementation 'com.google.android.gms:play-services-auth:17.0.0' //Added for google authentication

而且我已经在依赖项中将此添加到project / build.gradle中:

classpath 'com.google.gms:google-services:4.3.2' // Added for authentication

知道为什么按钮不出现?

EDIT 1

:按照要求,这里是整个XML代码:PS:正常按钮正常出现。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".Activity.LoginActivity">
<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleType="centerCrop"
        android:src="@drawable/image_bg_login">

    </ImageView>
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="100dp"
            android:textAlignment="center"
            android:textColor="#000"
            android:textSize="26sp"
            android:text="Things End. \n But memories last forever. \n Share your memories \n With the world"
            android:textStyle="bold|italic">

        </TextView>
    </RelativeLayout>
    <com.google.android.gms.common.SignInButton
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:text="Login"
        android:layout_marginLeft="50dp"
        android:layout_marginRight="50dp"
        android:layout_marginBottom="50dp"/>

</FrameLayout>
</RelativeLayout>

我正在关注有关如何在我的Android应用中实现Google身份验证的教程。我已经达到了在我的activity_login.xml文件中添加google预定义按钮的阶段,就像它的...

android xml android-studio
1个回答
0
投票

enter image description here试试这个,这是我获得代码的结果。”

© www.soinside.com 2019 - 2024. All rights reserved.