ArcLayout

public class ArcLayout


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 {@code anchorAngleDegrees} and {@code 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

ArcLayout.LayoutParams

Layout parameters for a widget added to an arc.

ArcLayout.Widget

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

Constants

static final @NonNull int

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

static final @NonNull int

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

static final @NonNull int

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

Public constructors

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

Public methods

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

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

@ArcLayout.AnchorType @NonNull int

Returns the anchor type used for this container.

@NonNull boolean

returns the layout direction

@Override @NonNull boolean
@Override @NonNull boolean
@Override @NonNull void
@NonNull void
setAnchorAngleDegrees(
    @FloatRange(from = "0.0f", to = "360.0f", toInclusive = "true") @NonNull float anchorAngleDegrees
)

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

@NonNull void

Sets the anchor type used for this container.

@NonNull void
setClockwise(@NonNull boolean clockwise)

Sets the layout direction

Inherited methods

From class View
@NonNull void
@NonNull void
@NonNull void
@NonNull ViewPropertyAnimator
@NonNull void
@NonNull void
@NonNull void
@NonNull void

This method is deprecated.

@NonNull void
@NonNull boolean
@NonNull boolean
@NonNull boolean
@NonNull boolean
@NonNull boolean
@NonNull boolean
canScrollVertically(@NonNull int direction)
final @NonNull void
@NonNull void
final @NonNull void
@NonNull boolean
@NonNull void
@NonNull void
static @NonNull int
combineMeasuredStates(@NonNull int curState, @NonNull int newState)
@NonNull void
@NonNull WindowInsets
computeSystemWindowInsets(
    @NonNull WindowInsets in,
    @NonNull Rect outLocalInsets
)
@NonNull AccessibilityNodeInfo
@NonNull void
@NonNull void

This method is deprecated.

@NonNull boolean
@NonNull boolean
dispatchNestedFling(
    @NonNull float velocityX,
    @NonNull float velocityY,
    @NonNull boolean consumed
)
@NonNull boolean
dispatchNestedPreFling(@NonNull float velocityX, @NonNull float velocityY)
@NonNull boolean
dispatchNestedPrePerformAccessibilityAction(
    @NonNull int action,
    @NonNull Bundle arguments
)
@NonNull boolean
dispatchNestedPreScroll(
    @NonNull int dx,
    @NonNull int dy,
    @NonNull Array<@NonNull int> consumed,
    @NonNull Array<@NonNull int> offsetInWindow
)
@NonNull boolean
dispatchNestedScroll(
    @NonNull int dxConsumed,
    @NonNull int dyConsumed,
    @NonNull int dxUnconsumed,
    @NonNull int dyUnconsumed,
    @NonNull Array<@NonNull int> offsetInWindow
)
@NonNull boolean
@NonNull void
draw(@NonNull Canvas canvas)
@NonNull void
drawableHotspotChanged(@NonNull float x, @NonNull float y)
final @NonNull T
<T extends View> findViewById(@NonNull int id)
final @NonNull T
<T extends View> findViewWithTag(@NonNull Object tag)
@NonNull void
forceHasOverlappingRendering(@NonNull boolean hasOverlappingRendering)
@NonNull void
@NonNull void
generateDisplayHash(
    @NonNull String hashAlgorithm,
    @NonNull Rect bounds,
    @NonNull Executor executor,
    @NonNull DisplayHashResultCallback callback
)
static @NonNull int
@NonNull View.AccessibilityDelegate
@NonNull int
@NonNull AccessibilityNodeProvider
@NonNull CharSequence
@NonNull int
@NonNull int
@NonNull float
@NonNull Animation
@NonNull Matrix
@NonNull IBinder
@NonNull Array<@NonNull int>
@NonNull Map<@NonNull Integer, @NonNull Integer>
@NonNull Array<@NonNull String>
final @NonNull AutofillId
@NonNull int
@NonNull AutofillValue
@NonNull Drawable
@NonNull BlendMode
@NonNull ColorStateList
@NonNull PorterDuff.Mode
@NonNull int
final @NonNull int
@NonNull float
@NonNull Rect
@NonNull boolean
final @NonNull boolean
final @NonNull ContentCaptureSession
@NonNull CharSequence
final @NonNull Context
final @NonNull boolean
static @NonNull int
getDefaultSize(@NonNull int size, @NonNull int measureSpec)
@NonNull Display
final @NonNull Array<@NonNull int>
@NonNull Bitmap

This method is deprecated.

@NonNull int

This method is deprecated.

@NonNull int