Skip to content

Most visited

Recently visited

navigation

CircularButton

public class CircularButton
extends View

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


This class is deprecated.
consider directly using the components from the design library - see link above.

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

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Follow Google Developers on WeChat

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience. (Dec 2017 Android Platform & Tools Survey)