ArcLayout

Added in 1.2.0

@UiThread
public class ArcLayout extends ViewGroup


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 ArcLayout.Widget 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 ArcLayout 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 CurvedTextView, which will lay itself out along the arc.

Summary

Nested types

Layout parameters for a widget added to an arc.

public interface ArcLayout.Widget

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

Constants

static final int

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

static final int

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

static final int

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

Public constructors

ArcLayout(
    @NonNull Context context,
    @Nullable AttributeSet attrs,
    int defStyleAttr
)
ArcLayout(
    @NonNull Context context,
    @Nullable AttributeSet attrs,
    int defStyleAttr,
    int defStyleRes
)

Public methods

@NonNull ViewGroup.LayoutParams
@FloatRange(from = 0.0, to = 360.0, toInclusive = true) float

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

int

Returns the anchor type used for this container.

@FloatRange(from = 0.0, to = 360.0, toInclusive = true) float

Returns the target angle that will be used by the layout when expanding child views with weights (see setWeight).

boolean

returns the layout direction

boolean
boolean
void
void
setAnchorAngleDegrees(
    @FloatRange(from = 0.0, to = 360.0, toInclusive = true) 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

void
setMaxAngleDegrees(
    @FloatRange(from = 0.0, to = 360.0, toInclusive = true) float maxAngleDegrees
)

Sets the target angle that will be used by the layout when expanding child views with weights (see setWeight).

Protected methods

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

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
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 float
static final float
static final float
static final float
static final float
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.view.View
void
void
void
ViewPropertyAnimator
void

This method is deprecated.

void
boolean
void
void

This method is deprecated.

void
boolean
boolean
boolean
boolean
boolean
canScrollHorizontally(int direction)
boolean
canScrollVertically(int direction)
final void
void
final void
boolean
void
void
void
static int
combineMeasuredStates(int curState, int newState)
int
int
int
void
WindowInsets
int
int
int
AccessibilityNodeInfo
void
void

This method is deprecated.

boolean
boolean
dispatchNestedFling(float velocityX, float velocityY, boolean consumed)
boolean
dispatchNestedPreFling(float velocityX, float velocityY)
boolean
dispatchNestedPrePerformAccessibilityAction(
    int action,
    Bundle arguments
)
boolean
dispatchNestedPreScroll(
    int dx,
    int dy,
    int[] consumed,
    int[] offsetInWindow
)
boolean
dispatchNestedScroll(
    int dxConsumed,
    int dyConsumed,
    int dxUnconsumed,
    int dyUnconsumed,
    int[] offsetInWindow
)
boolean
void
draw(Canvas canvas)
void
drawableHotspotChanged(float x, float y)
final OnBackInvokedDispatcher
final T
<T extends View> findViewById(int id)
final T
<T extends View> findViewWithTag(Object tag)
boolean

This method is deprecated.

void
forceHasOverlappingRendering(boolean hasOverlappingRendering)
void
void
generateDisplayHash(
    String hashAlgorithm,
    Rect bounds,
    Executor executor,
    DisplayHashResultCallback callback
)
static int
View.AccessibilityDelegate
int
AccessibilityNodeProvider
CharSequence
int
int
String
String
float
Animation
Matrix
IBinder
int[]
Map<IntegerInteger>
String[]
final AutofillId
int
AutofillValue