lightbulb_outline Help shape the future of the Google Play Console, Android Studio, and Firebase. Start survey

CircularButton

public class CircularButton
extends View

java.lang.Object
   ↳ android.view.View
     ↳ android.support.wearable.view.CircularButton


This class is deprecated.
consider using the Floating Action Button instead.

A circular button in the style of a Floating Action Button, with support for ripple touch effects and elevation animation.

Summary

Constants

int SCALE_MODE_CENTER

int SCALE_MODE_FIT

Inherited constants

From class android.view.View

Inherited fields

From class android.view.View

Public constructors

CircularButton(Context context)
CircularButton(Context context, AttributeSet attrs)
CircularButton(Context context, AttributeSet attrs, int defStyleAttr)
CircularButton(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)

Public methods

Drawable getImageDrawable()

Returns the optional image to displayed on top of the button.

int getImageScaleMode()

Returns the scaling mode used for the image.

boolean onTouchEvent(MotionEvent event)
void setBackgroundDrawable(Drawable background)
void setColor(ColorStateList colorStateList)

Sets the background color of the circular button.

void setColor(int color)

Sets the background color of the circular button.

void setImageDrawable(Drawable drawable)

Sets an optional image to be displayed on top of the button.

void setImageResource(int drawableRes)

Sets an optional image to be displayed on top of the button.

void setImageScaleMode(int scaleMode)

Sets the scaling mode used for the image.

void setPressedTranslationZ(float translationZ)
void setRippleColor(int rippleColor)

Protected methods

void drawableStateChanged()
void onDraw(Canvas canvas)
void onLayout(boolean changed, int l, int t, int r, int b)
void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
boolean verifyDrawable(Drawable who)

Inherited methods

From class android.view.View
From class java.lang.Object
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.accessibility.AccessibilityEventSource

Constants

SCALE_MODE_CENTER

int SCALE_MODE_CENTER

Constant Value: 1 (0x00000001)

SCALE_MODE_FIT

int SCALE_MODE_FIT

Constant Value: 0 (0x00000000)

Public constructors

CircularButton

CircularButton (Context context)

Parameters
context Context

CircularButton

CircularButton (Context context, 
                AttributeSet attrs)

Parameters
context Context

attrs AttributeSet

CircularButton

CircularButton (Context context, 
                AttributeSet attrs, 
                int defStyleAttr)

Parameters
context Context

attrs AttributeSet

defStyleAttr int

CircularButton

CircularButton (Context context, 
                AttributeSet attrs, 
                int defStyleAttr, 
                int defStyleRes)

Parameters
context Context

attrs AttributeSet

defStyleAttr int

defStyleRes int

Public methods

getImageDrawable

Drawable getImageDrawable ()

Returns the optional image to displayed on top of the button.

Returns
Drawable

getImageScaleMode

int getImageScaleMode ()

Returns the scaling mode used for the image.

Value is one of:

SCALE_MODE_CENTER
Center the image within the button and draw without any scaling.
SCALE_MODE_FIT
Draw the image scaled to fit within the circular button.

Returns
int

onTouchEvent

boolean onTouchEvent (MotionEvent event)

Parameters
event MotionEvent

Returns
boolean

setBackgroundDrawable

void setBackgroundDrawable (Drawable background)

Parameters
background Drawable

setColor

void setColor (ColorStateList colorStateList)

Sets the background color of the circular button.

Parameters
colorStateList ColorStateList

setColor

void setColor (int color)

Sets the background color of the circular button.

Parameters
color int

setImageDrawable

void setImageDrawable (Drawable drawable)

Sets an optional image to be displayed on top of the button.

Parameters
drawable Drawable

setImageResource

void setImageResource (int drawableRes)

Sets an optional image to be displayed on top of the button.

Parameters
drawableRes int

setImageScaleMode

void setImageScaleMode (int scaleMode)

Sets the scaling mode used for the image.

Must be one of:

SCALE_MODE_CENTER
Center the image within the button and draw without any scaling.
SCALE_MODE_FIT
Draw the image scaled to fit within the circular button.

Parameters
scaleMode int

setPressedTranslationZ

void setPressedTranslationZ (float translationZ)

Parameters
translationZ float

setRippleColor

void setRippleColor (int rippleColor)

Parameters
rippleColor int

Protected methods

drawableStateChanged

void drawableStateChanged ()

onDraw

void onDraw (Canvas canvas)

Parameters
canvas Canvas

onLayout

void onLayout (boolean changed, 
                int l, 
                int t, 
                int r, 
                int b)

Parameters
changed boolean

l int

t int

r int

b int

onMeasure

void onMeasure (int widthMeasureSpec, 
                int heightMeasureSpec)

Parameters
widthMeasureSpec int

heightMeasureSpec int

verifyDrawable

boolean verifyDrawable (Drawable who)

Parameters
who Drawable

Returns
boolean