圆角谷歌登录按钮-android
我正在尝试在我的应用程序中添加“使用谷歌登录”功能。我使用以下代码添加谷歌登录按钮圆角谷歌登录按钮-android,android,google-signin,Android,Google Signin,我正在尝试在我的应用程序中添加“使用谷歌登录”功能。我使用以下代码添加谷歌登录按钮 <com.google.android.gms.common.SignInButton android:id="@+id/btn_google_signin" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="24dp" andro
<com.google.android.gms.common.SignInButton
android:id="@+id/btn_google_signin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:background="?attr/selectableItemBackground"
android:elevation="2dp"></com.google.android.gms.common.SignInButton>
这是渲染一个矩形按钮。但我想要圆角按钮。有没有办法定制这个圆角按钮
附言-我不想定制普通按钮。我特别期待谷歌登录按钮。如果您只知道这些,请回复。drawable文件夹中的round_style.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_pressed="true" >
<shape android:shape="rectangle" >
<corners android:radius="3dip" />
<stroke android:width="1dip" android:color="#5e7974" />
<gradient android:angle="-90" android:startColor="#345953" android:endColor="#689a92" />
</shape>
</item>
<item android:state_focused="true">
<shape android:shape="rectangle" >
<corners android:radius="3dip" />
<stroke android:width="1dip" android:color="#5e7974" />
<solid android:color="#58857e"/>
</shape>
</item>
<item >
<shape android:shape="rectangle" >
<corners android:radius="3dip" />
<stroke android:width="1dip" android:color="#5e7974" />
<gradient android:angle="-90" android:startColor="#8dbab3" android:endColor="#58857e" />
</shape>
</item>
</selector>
或
现在使用
<com.google.android.gms.common.SignInButton
android:id="@+id/btn_google_signin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:background="@drawable/round_style"
android:elevation="2dp"></com.google.android.gms.common.SignInButton>
您可以使用卡片视图。然后将登录按钮放入CardView,如下所示:
<android.support.v7.widget.CardView 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="wrap_content"
android:layout_height="match_parent"
android:layout_marginBottom="4dp"
android:layout_marginRight="4dp"
android:layout_marginTop="4dp"
app:cardCornerRadius="4dp"
app:cardElevation="2dp">
<com.google.android.gms.common.SignInButton
android:id="@+id/btn_google_signin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:background="?attr/selectableItemBackground"
android:elevation="2dp"></com.google.android.gms.common.SignInButton>
</android.support.v7.widget.CardView>
你需要有可绘制的背景。查看这篇文章,了解正常按钮的答案,我知道这一点。对于谷歌登录按钮来说,非常具体。使用您的解决方案,圆形背景位于背面,按钮位于圆形背景上。这会在登录按钮上添加一个带有圆角的背景,但不是圆角
<android.support.v7.widget.CardView 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="wrap_content"
android:layout_height="match_parent"
android:layout_marginBottom="4dp"
android:layout_marginRight="4dp"
android:layout_marginTop="4dp"
app:cardCornerRadius="4dp"
app:cardElevation="2dp">
<com.google.android.gms.common.SignInButton
android:id="@+id/btn_google_signin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:background="?attr/selectableItemBackground"
android:elevation="2dp"></com.google.android.gms.common.SignInButton>
</android.support.v7.widget.CardView>