首页 > 解决方案 > 如何使用 XML 在 android 中创建 google 登录/向上按钮?

问题描述

我不想在我的 Android 应用程序中使用任何图像

有没有办法只用XML制作它? 在此处输入图像描述

标签: xmlandroid-layoutbutton

解决方案


尝试使用此代码在 xml 布局中创建相同的视图

主要的.xml

<androidx.cardview.widget.CardView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="@dimen/dimen_15"
            app:cardCornerRadius="@dimen/dimen_15">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:padding="@dimen/dimen_5">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="SIGN IN/UP WITH GOOGLE"
                    android:drawableLeft="@drawable/ic_google"
                    android:drawablePadding="@dimen/dimen_13"
                    android:gravity="center"/>
            </LinearLayout>
        </androidx.cardview.widget.CardView>

截屏


推荐阅读