SignInButton

public final class SignInButton extends FrameLayout implements View.OnClickListener


The Google sign-in button to authenticate the user. Note that this class only handles the visual aspects of the button. In order to trigger an action, register a listener using setOnClickListener.

Note that you must explicitly call setOnClickListener. Do not register a listener via XML, or you won't receive your callbacks.

Summary

Nested types

@Retention(value = RetentionPolicy.SOURCE)
@IntDef(value = )
public annotation SignInButton.ButtonSize

Size constants - enumeration of supported sizes.

@Retention(value = RetentionPolicy.SOURCE)
@IntDef(value = )
public annotation SignInButton.ColorScheme

Color constants - enumeration of supported color schemes.

Constants

static final int

Google Play services will decide the color scheme for sign-in button.

static final int

The dark color scheme of the sign-in button.

static final int

The light color scheme of the sign-in button.

static final int

The icon-only size of the Google sign-in button.

static final int

The standard size of the Google sign-in button.

static final int

The wide size of the Google sign-in button.

Public constructors

SignInButton(Context context, @Nullable AttributeSet attrs, int defStyle)

Public methods

void
onClick(View view)
void

Set the color scheme of the button to use.

void
setEnabled(boolean enabled)
void
void
setScopes(Scope[] scopes)

This method is deprecated.

Setting scopes will no longer impact the branding.

void

Set the size of the button to use.

void
setStyle(
    @SignInButton.ButtonSize int buttonSize,
    @SignInButton.ColorScheme int colorScheme
)

Set the desired style of button to use.

void
@InlineMe(replacement = "this.setStyle(buttonSize, colorScheme)")
setStyle(
    @SignInButton.ButtonSize int buttonSize,
    @SignInButton.ColorScheme int colorScheme,
    Scope[] scopes
)

This method is deprecated.

Setting scopes will no longer impact the branding.

Inherited Constants

From android.view.View
static final int
static final int
static final int
static final int
static final int
static final int
static final Property<ViewFloat>
static final int
static final String
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE = "creditCardExpirationDate"
static final String
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY = "creditCardExpirationDay"
static final String
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH = "creditCardExpirationMonth"
static final String
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR = "creditCardExpirationYear"
static final String
static final String
AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE = "creditCardSecurityCode"
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int
static final int
static final int
static final int
static final int
static final int
static final int[]
static final int[]
static final int[]
static final int[]
static final int
static final int
static final int
static final int
static final int
static final int
static final int
GONE = 8
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
KEEP_SCREEN_ON = 67108864
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
NO_ID = -1
static final int
static final int
static final int
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final int[]
static final Property<ViewFloat>
static final Property<ViewFloat>
static final Property<ViewFloat>
static final Property<ViewFloat>
static final Property<ViewFloat>
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int[]
static final int[]
static final int
static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final Property<ViewFloat>
static final Property<ViewFloat>
static final Property<ViewFloat>
static final String
VIEW_LOG_TAG = "View"
static final int
static final int[]
static final Property<ViewFloat>
static final Property<ViewFloat>
static final Property<ViewFloat>
From android.view.ViewGroup
static final int
static final int
static final int
static final int
static final int
static final int
static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

static final int

This field is deprecated.

Inherited methods

From android.widget.FrameLayout
From android.view.View
void
void
void
ViewPropertyAnimator
void
void
boolean
void
void

This method is deprecated.

void
boolean
boolean
boolean
boolean
boolean
boolean
final void
void
final void
boolean
void
void
static int
combineMeasuredStates(int p, int p1)
int
int
int
void
WindowInsets
int
int
int
AccessibilityNodeInfo
void
void

This method is deprecated.

boolean
boolean
dispatchNestedFling(float p, float p1, boolean p2)
boolean
dispatchNestedPreFling(float p, float p1)
boolean
boolean
dispatchNestedPreScroll(int p, int p1, int[] p2, int[] p3)
boolean
dispatchNestedScroll(int p, int p1, int p2, int p3, int[] p4)
boolean
void
void
drawableHotspotChanged(float p, float p1)
final OnBackInvokedDispatcher
final T
<T extends View> findViewById(int p)
final T
<T extends View> findViewWithTag(Object p)
boolean

This method is deprecated.

void
void
void
generateDisplayHash(
    String p,
    Rect p1,
    Executor p2,
    DisplayHashResultCallback p3
)
static int
View.AccessibilityDelegate
int
AccessibilityNodeProvider
CharSequence
int
int
String
String
float
Animation
Matrix
IBinder
int[]
Map<IntegerInteger>
String[]
final AutofillId
int
AutofillValue
Drawable
BlendMode
ColorStateList
PorterDuff.Mode
int
final int
float
int
float
Rect
boolean
final boolean
final ContentCaptureSession
CharSequence
final Context
ContextMenu.ContextMenuInfo
final boolean
static int
getDefaultSize(int p, int p1)
Display
final int[]
Bitmap

This method is deprecated.

int

This method is deprecated.

int

This method is deprecated.

void
long
float
int
boolean
boolean
int
ArrayList<View>
void
Drawable
int
BlendMode
ColorStateList
PorterDuff.Mode
boolean
Handler
float
float
float
float
Runnable
final boolean
final int
void
int
int
Drawable
Drawable
int
int
int
int
boolean
KeyEvent.DispatcherState
int
int
int
ViewGroup.LayoutParams
final int
float
int
final boolean
void
void
void
Matrix
final int
final int
final int
final int
final int
int
int
int
int
int
int
int
int
View.OnFocusChangeListener
int
ViewOutlineProvider
int
int
ViewOverlay
int
int
int
int
int
int
final ViewParent
ViewParent
float
float
PointerIcon
final List<Rect>
String[]
Resources
final boolean
final int
float
int
AttachedSurfaceControl
View
WindowInsets
float
float
float
float
float
int
int
int
int
int
int
final int
final int
int
int
final CharSequence
StateListAnimator
int
int
List<Rect>
int

This method is deprecated.

Object
int
int
CharSequence
final int
float
int
TouchDelegate
ArrayList<View>
float
String
float
float
float
long
int
int
Drawable
Drawable
int
ViewTranslationResponse
ViewTreeObserver
int
final int
int
WindowId
WindowInsetsController
int

This method is deprecated.

IBinder
int
void
float
float
float
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
static View
inflate(Context p, int p1, ViewGroup p2)
void

This method is deprecated.

void
void
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean

This method is deprecated.

boolean
boolean
final boolean
final boolean
boolean
final boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
final boolean
final boolean
boolean
boolean
boolean
final boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
final boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
final boolean
boolean
boolean
final boolean
boolean
boolean
boolean
boolean
boolean
View
final void
measure(int p, int p1)
static int[]
mergeDrawableStates(int[] p, int[] p1)
void
void
void
void
WindowInsets
void
boolean
boolean
void
void
InputConnection
void
void
onCreateVirtualViewTranslationRequests(
    long[] p,
    int[] p1,
    Consumer<ViewTranslationRequest> p2
)
void
boolean
void
void
final void
boolean
void
void
void
onFocusChanged(boolean p, int p1, Rect p2)
boolean
void
onHoverChanged(boolean p)
boolean
void
void
boolean
onKeyDown(int p, KeyEvent p1)
boolean
onKeyLongPress(int p, KeyEvent p1)
boolean
onKeyMultiple(int p, int p1, KeyEvent p2)
boolean
onKeyPreIme(int p, KeyEvent p1)
boolean
onKeyShortcut(int p, KeyEvent p1)
boolean
onKeyUp(int p, KeyEvent p1)
void
onOverScrolled(int p, int p1, boolean p2, boolean p3)
void
void
void
void
void
void
void
ContentInfo
void
void
Parcelable
void
void
onScrollCaptureSearch(
    Rect p,
    Point p1,
    Consumer<ScrollCaptureTarget> p2
)
void
onScrollChanged(int p, int p1, int p2, int p3)
boolean
onSetAlpha(int p)
void
onSizeChanged(int p, int p1, int p2, int p3)
void
boolean
boolean
void
void
void
void
void
void

This method is deprecated.

void
boolean
overScrollBy(
    int p,
    int p1,
    int p2,
    int p3,
    int p4,
    int p5,
    int p6,
    int p7,
    boolean p8
)
boolean
boolean
boolean
performContextClick(float p, float p1)
boolean
boolean
ContentInfo
void
boolean
boolean
postDelayed(Runnable p, long p1)
void
void
void
void
void
void
void
boolean
void
void
void
void
void

This method is deprecated.

final boolean
void
void
boolean
final void
final T
<T extends View> requireViewById(int p)
void
static int
resolveSize(int p, int p1)
static int
resolveSizeAndState(int p, int p1, int p2)
void
final void
saveAttributeDataForStyleable(
    Context p,
    int[] p1,
    AttributeSet p2,
    TypedArray p3,
    int p4,
    int p5
)
void
void
scheduleDrawable(Drawable p, Runnable p1, long p2)
void
scrollBy(int p, int p1)
void
scrollTo(int p, int p1)
void
void
void
void
void
void
void
void
void
void
setActivated(boolean p)
void
void
void
void
setAlpha(float p)
void
void
void
void
setAutofillHints(String[] p)
void
void
void
void

This method is deprecated.

void
void
void
void
final void
setBottom(int p)
void
void
setClickable(boolean p)
void
void
setClipToOutline(boolean p)
void
void
void
void
void

This method is deprecated.

void

This method is deprecated.

void

This method is deprecated.

void
void
setElevation(float p)
void
void
void
void
setFocusable(boolean p)
void
void
void
void
void
void
void
void
setHandwritingBoundsOffsets(float p, float p1, float p2, float p3)
void
void
void
void
void
void
void
void
setHovered(boolean p)
void
setId(int p)
void
void
void
void
setIsCredential(boolean p)
void
void
setKeepScreenOn(boolean p)
void
void
setLabelFor(int p)
void
void
setLayerType(int p, Paint p1)
void
void
final void
setLeft(int p)
final void
setLeftTopRightBottom(int p, int p1, int p2, int p3)
void
setLongClickable(boolean p)
final void
setMeasuredDimension(int p, int p1)
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void

This method is deprecated.

void
void
void
void
void
void
setPadding(int p, int p1, int p2, int p3)
void
setPaddingRelative(int p, int p1, int p2, int p3)
void
setPivotX(float p)
void
setPivotY(float p)
void
final void
setPreferKeepClear(boolean p)
final void
void
setPressed(boolean p)
void
final void
final void
setRight(int p)
void
setRotation(float p)
void
setRotationX(float p)
void
setRotationY(float p)
void
setSaveEnabled(boolean p)
void
void
setScaleX(float p)
void
setScaleY(float p)
void
void
void
void
void
final void
void
void
setScrollContainer(boolean p)
void
void
setScrollX(int p)
void
setScrollY(int p)
void
void
setSelected(boolean p)
void
void
void
void
void

This method is deprecated.

void
void
void
void
final void
setTop(int p)
void
void
final void
void
void
setTranslationX(float p)
void
setTranslationY(float p)
void
setTranslationZ(float p)
void
void
void
void
void
void
void
void

This method is deprecated.

void
setWillNotDraw(boolean p)
void
setX(float p)
void
setY(float p)
void
setZ(float p)
boolean
ActionMode
void
final boolean

This method is deprecated.

final boolean
startDragAndDrop(
    ClipData p,
    View.DragShadowBuilder p1,
    Object p2,
    int p3
)
boolean
void
String
void
void
void
final void
boolean
boolean

This method is deprecated.

boolean
From android.view.ViewGroup
void
void
void
addFocusables(ArrayList<View> p, int p1, int p2)
void
boolean
void
void
boolean
void
attachLayoutAnimationParameters(
    View p,
    ViewGroup.LayoutParams p1,
    int p2,
    int p3
)
void
void
boolean
void
void
void
void
void
void
void
debug(int p)
void
void
void
detachViewsFromParent(int p, int p1)
WindowInsets
boolean
void
void
dispatchCreateViewTranslationRequest(
    Map<AutofillId, long[]> p,
    int[] p1,
    TranslationCapability p2,
    List<ViewTranslationRequest> p3
)
void
boolean
void
void
dispatchDrawableHotspotChanged(float p, float p1)
void
void
boolean
boolean
boolean
boolean
boolean
boolean
void
void
void
void
void
void
void
void
dispatchSetPressed(boolean p)
void
void
void

This method is deprecated.

void
boolean
boolean
boolean
void
void
void
void
WindowInsets
WindowInsetsAnimation.Bounds
void

This method is deprecated.

void
boolean
drawChild(Canvas p, View p1, long p2)
void
void
View
OnBackInvokedDispatcher
void
View
focusSearch(View p, int p1)
void
boolean
View
getChildAt(int p)
int
int
getChildDrawingOrder(int p, int p1)
static int
getChildMeasureSpec(int p, int p1, int p2)
boolean
boolean
boolean
boolean
int
View
LayoutAnimationController
Animation.AnimationListener
int
LayoutTransition
int
ViewGroupOverlay
int

This method is deprecated.

boolean
boolean
boolean
int
final void

This method is deprecated.

ViewParent

This method is deprecated.

boolean

This method is deprecated.

boolean

This method is deprecated.

boolean
boolean

This method is deprecated.

boolean
boolean
boolean
void
final void
layout(int p, int p1, int p2, int p3)
void
measureChild(View p, int p1, int p2)
void
measureChildWithMargins(View p, int p1, int p2, int p3, int p4)
void
measureChildren(int p, int p1)
void
final void
final void
void
int[]
void
void
boolean
boolean
boolean
onNestedFling(View p, float p1, float p2, boolean p3)
boolean
onNestedPreFling(View p, float p1, float p2)
boolean
void
onNestedPreScroll(View p, int p1, int p2, int[] p3)
void
onNestedScroll(View p, int p1, int p2, int p3, int p4)
void
onNestedScrollAccepted(View p, View p1, int p2)
boolean
boolean
PointerIcon
boolean
onStartNestedScroll(View p, View p1, int p2)
void
void
void
void
void
void
void
removeDetachedView(View p, boolean p1)
void
void
removeViewAt(int p)
void
void
removeViews(int p, int p1)
void
removeViewsInLayout(int p, int p1)
void
boolean
requestChildRectangleOnScreen(View p, Rect p1, boolean p2)
void
boolean
requestFocus(int p, Rect p1)
boolean
void
boolean
void
void
void

This method is deprecated.

void

This method is deprecated.

void

This method is deprecated.

void
void

This method is deprecated.

void
setClipChildren(boolean p)
void
setClipToPadding(boolean p)
void
void
void
void
void
void
void
void

This method is deprecated.

void
void
void
setTransitionGroup(boolean p)
void
boolean
ActionMode
void
void
void
suppressLayout(boolean p)
void

Constants

COLOR_AUTO

public static final int COLOR_AUTO = 2

Google Play services will decide the color scheme for sign-in button.

COLOR_DARK

public static final int COLOR_DARK = 0

The dark color scheme of the sign-in button.

COLOR_LIGHT

public static final int COLOR_LIGHT = 1

The light color scheme of the sign-in button.

SIZE_ICON_ONLY

public static final int SIZE_ICON_ONLY = 2

The icon-only size of the Google sign-in button.

SIZE_STANDARD

public static final int SIZE_STANDARD = 0

The standard size of the Google sign-in button.

SIZE_WIDE

public static final int SIZE_WIDE = 1

The wide size of the Google sign-in button.

Public constructors

SignInButton

public SignInButton(Context context)

SignInButton

public SignInButton(Context context, @Nullable AttributeSet attrs)

SignInButton

public SignInButton(Context context, @Nullable AttributeSet attrs, int defStyle)

Public methods

onClick

public void onClick(View view)

setColorScheme

public void setColorScheme(@SignInButton.ColorScheme int colorScheme)

Set the color scheme of the button to use. The size and branding scheme will remain unchanged.

Parameters
@SignInButton.ColorScheme int colorScheme

The color scheme to use for the button. See ColorScheme

setEnabled

public void setEnabled(boolean enabled)

setOnClickListener

public void setOnClickListener(@Nullable View.OnClickListener listener)

setScopes

public void setScopes(Scope[] scopes)

Set the scopes your app will use to sign in and the sign in button will choose the right branding for you. The color scheme and the size will remain unchanged.

Parameters
Scope[] scopes

A scope array.

setSize

public void setSize(@SignInButton.ButtonSize int buttonSize)

Set the size of the button to use. The color and branding scheme will remain unchanged.

Parameters
@SignInButton.ButtonSize int buttonSize

The size of the button to display. See ButtonSize

setStyle

public void setStyle(
    @SignInButton.ButtonSize int buttonSize,
    @SignInButton.ColorScheme int colorScheme
)

Set the desired style of button to use. This will update the button to use the specified size and color scheme.

Parameters
@SignInButton.ButtonSize int buttonSize

The size of the button to display. See ButtonSize

@SignInButton.ColorScheme int colorScheme

The color scheme to use for the button. See ColorScheme

setStyle

@InlineMe(replacement = "this.setStyle(buttonSize, colorScheme)")
public void setStyle(
    @SignInButton.ButtonSize int buttonSize,
    @SignInButton.ColorScheme int colorScheme,
    Scope[] scopes
)

Set the desired style of button to use. This will update the button to use the specified size, color scheme and corresponding branding.

Parameters
@SignInButton.ButtonSize int buttonSize

The size of the button to display. See ButtonSize

@SignInButton.ColorScheme int colorScheme

The color scheme to use for the button. See ColorScheme

Scope[] scopes

The scopes your app will use to sign in.