public class WearArcLayout
extends ViewGroup

   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ androidx.wear.widget.WearArcLayout

Container which will lay its elements out on an arc. Elements will be relative to a given anchor angle (where 0 degrees = 12 o clock), where the layout relative to the anchor angle is controlled using anchorAngleDegrees and anchorType. The thickness of the arc is calculated based on the child element with the greatest height (in the case of Android widgets), or greatest thickness (for curved widgets). By default, the container lays its children one by one in clockwise direction. The attribute 'clockwise' can be set to false to make the layout direction as anti-clockwise. These two types of widgets will be drawn as follows.

Standard Android Widgets:

These widgets will be drawn as usual, but placed at the correct position on the arc, with the correct amount of rotation applied. As an example, for an Android Text widget, the text baseline would be drawn at a tangent to the arc. The arc length of a widget is obtained by measuring the width of the widget, and transforming that to the length of an arc on a circle.

A standard Android widget will be measured as usual, but the maximum height constraint will be capped at the minimum radius of the arc (i.e. width / 2).

"Curved" widgets:

Widgets which implement WearArcLayout.ArcLayoutWidget are expected to draw themselves within an arc automatically. These widgets will be measured with the full dimensions of the arc container. They are also expected to provide their thickness (used when calculating the thickness of the arc) and the current sweep angle (used for laying out when drawing). Note that the WearArcLayout will apply a rotation transform to the canvas before drawing this child; the inner child need not perform any rotations itself.

An example of a widget which implements this interface is WearCurvedTextView, which will lay itself out along the arc.


Nested classes

interface WearArcLayout.ArcLayoutWidget

Interface for a widget which knows it is being rendered inside an arc, and will draw itself accordingly. 

class WearArcLayout.LayoutParams

Layout parameters for a widget added to an arc. 



Anchor at the center of the set of elements drawn within this container.


Anchor at the end of the set of elements drawn within this container.


Anchor at the start of the set of elements drawn within this container.

Inherited constants

Inherited fields

Public constructors

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

Public methods

ViewGroup.LayoutParams generateLayoutParams(AttributeSet attrs)
float getAnchorAngleDegrees()

Returns the anchor angle used for this container, in degrees.

int getAnchorType()

Returns the anchor type used for this container.

boolean getClockwise()

returns the layout direction

boolean onInterceptTouchEvent(MotionEvent event)
boolean onTouchEvent(MotionEvent event)
void requestLayout()
void setAnchorAngleDegrees(float anchorAngleDegrees)

Sets the anchor angle used for this container, in degrees.

void setAnchorType(int anchorType)

Sets the anchor type used for this container.

void setClockwise(boolean clockwise)

Sets the layout direction

Protected methods

boolean checkLayoutParams(ViewGroup.LayoutParams p)
boolean drawChild(Canvas canvas, View child, long drawingTime)
ViewGroup.LayoutParams generateDefaultLayoutParams()
ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams p)
void onLayout(boolean changed, int l, int t, int r, int b)
void onMeasure(int widthMeasureSpec, int heightMeasureSpec)

Inherited methods