CircularFlow

public class CircularFlow
extends View

java.lang.Object
   ↳ android.view.View
     ↳ androidx.constraintlayout.helper.widget.CircularFlow


CircularFlow virtual layout. Allows positioning of referenced widgets circular. The elements referenced are indicated via constraint_referenced_ids, as with other ContraintHelper implementations. XML attributes that are needed:

  • constraint_referenced_ids = "view2, view3, view4,view5,view6"
  • . It receives id's of the views that will add the references.
  • circularflow_viewCenter = "view1"
  • . It receives the id of the view of the center where the views received in constraint_referenced_ids will be referenced.
  • circularflow_angles = "45,90,135,180,225"
  • . Receive the angles that you will assign to each view.
  • circularflow_radiusInDP = "90,100,110,120,130"
  • . Receive the radios in DP that you will assign to each view.
Example in XML: DEFAULT radius - If you add a view and don't set its radius, the default value will be 0. DEFAULT angles - If you add a view and don't set its angle, the default value will be 0. Recommendation - always set radius and angle for all views in constraint_referenced_ids

Summary

Inherited constants

Fields

protected HashMap<Integer, String> mMap

Inherited fields

Public constructors

CircularFlow(Context context)
CircularFlow(Context context, AttributeSet attrs)
CircularFlow(Context context, AttributeSet attrs, int defStyleAttr)

Public methods

void addView(View view)

Add a view to the helper.

void addViewToCircularFlow(View view, int radius, float angle)

Add a view to the CircularFlow.

boolean containsId(int id)
float[] getAngles()
int[] getRadius()
int[] getReferencedIds()

Helpers typically reference a collection of ids

int indexFromId(int id)
boolean isUpdatable(View view)
void loadParameters(ConstraintSet.Constraint constraint, HelperWidget child, ConstraintLayout.LayoutParams layoutParams, SparseArray<ConstraintWidget> mapIdToWidget)
void onAttachedToWindow()
void onMeasure(VirtualLayout layout, int widthMeasureSpec, int heightMeasureSpec)
static float[] removeElementFromArray(float[] array, int index)
static int[] removeElementFromArray(int[] array, int index)
int removeView(View view)

Remove a given view from the helper.

void resolveRtl(ConstraintWidget widget, boolean isRtl)
void setDefaultAngle(float angle)

Set default Angle for CircularFlow.

void setDefaultRadius(int radius)

Set default Radius for CircularFlow.

void setReferencedIds(int[] ids)

Helpers typically reference a collection of ids

void setTag(int key, Object tag)
void updateAngle(View view, float angle)

Update angle from a view in CircularFlow.

void updatePostConstraints(ConstraintLayout container)
void updatePreDraw(ConstraintLayout container)
void updatePreLayout(ConstraintWidgetContainer container, Helper helper, SparseArray<ConstraintWidget> map)
void updateRadius(View view, int radius)

Update radius from a view in CircularFlow.

void updateReference(View view, int radius, float angle)

Update angle and radius from a view in CircularFlow.

Protected methods

View[] getViews(ConstraintLayout layout)
void init(AttributeSet attrs)

Inherited methods

Fields

mMap

protected HashMap<Integer, String> mMap

Public constructors

CircularFlow

public CircularFlow (Context context)

Parameters
context Context

CircularFlow

public CircularFlow (Context context, 
                AttributeSet attrs)

Parameters
context Context

attrs AttributeSet

CircularFlow

public CircularFlow (Context context, 
                AttributeSet attrs, 
                int defStyleAttr)

Parameters
context Context

attrs AttributeSet

defStyleAttr int

Public methods

addView

public void addView (View view)

Add a view to the helper. The referenced view need to be a child of the helper's parent. The view also need to have its id set in order to be added.

addViewToCircularFlow

public void addViewToCircularFlow (View view, 
                int radius, 
                float angle)

Add a view to the CircularFlow. The referenced view need to be a child of the container parent. The view also need to have its id set in order to be added. The views previous need to have its radius and angle set in order to be added correctly a new view.

containsId

public boolean containsId (int id)

Parameters
id int

Returns
boolean

getAngles

public float[] getAngles ()

Returns
float[]

getRadius

public int[] getRadius ()

Returns
int[]

getReferencedIds

public int[] getReferencedIds ()

Helpers typically reference a collection of ids

Returns
int[] ids referenced

indexFromId

public int indexFromId (int id)

Parameters
id int

Returns
int

isUpdatable

public boolean isUpdatable (View view)

Parameters
view View

Returns
boolean

loadParameters

public void loadParameters (ConstraintSet.Constraint constraint, 
                HelperWidget child, 
                ConstraintLayout.LayoutParams layoutParams, 
                SparseArray<ConstraintWidget> mapIdToWidget)

Parameters
constraint ConstraintSet.Constraint

child HelperWidget

layoutParams ConstraintLayout.LayoutParams

mapIdToWidget SparseArray

onAttachedToWindow

public void onAttachedToWindow ()

onMeasure

public void onMeasure (VirtualLayout layout, 
                int widthMeasureSpec, 
                int heightMeasureSpec)

Parameters
layout VirtualLayout

widthMeasureSpec int

heightMeasureSpec int

removeElementFromArray

public static float[] removeElementFromArray (float[] array, 
                int index)

Parameters
array float

index int

Returns
float[]

removeElementFromArray

public static int[] removeElementFromArray (int[] array, 
                int index)

Parameters
array int

index int

Returns
int[]

removeView

public int removeView (View view)

Remove a given view from the helper.

Returns
int index of view removed

resolveRtl

public void resolveRtl (ConstraintWidget widget, 
                boolean isRtl)

Parameters
widget ConstraintWidget

isRtl boolean

setDefaultAngle

public void setDefaultAngle (float angle)

Set default Angle for CircularFlow.

setDefaultRadius

public void setDefaultRadius (int radius)

Set default Radius for CircularFlow.

setReferencedIds

public void setReferencedIds (int[] ids)

Helpers typically reference a collection of ids

Parameters
ids int

Returns
void ids referenced

setTag

public void setTag (int key, 
                Object tag)

Parameters
key int

tag Object

updateAngle

public void updateAngle (View view, 
                float angle)

Update angle from a view in CircularFlow. The referenced view need to be a child of the container parent. The view also need to have its id set in order to be added.

updatePostConstraints

public void updatePostConstraints (ConstraintLayout container)

Parameters
container ConstraintLayout

updatePreDraw

public void updatePreDraw (ConstraintLayout container)

Parameters
container ConstraintLayout

updatePreLayout

public void updatePreLayout (ConstraintWidgetContainer container, 
                Helper helper, 
                SparseArray<ConstraintWidget> map)

Parameters
container ConstraintWidgetContainer

helper Helper

map SparseArray

updateRadius

public void updateRadius (View view, 
                int radius)

Update radius from a view in CircularFlow. The referenced view need to be a child of the container parent. The view also need to have its id set in order to be added.

updateReference

public void updateReference (View view, 
                int radius, 
                float angle)

Update angle and radius from a view in CircularFlow. The referenced view need to be a child of the container parent. The view also need to have its id set in order to be added.

Protected methods

getViews

protected View[] getViews (ConstraintLayout layout)

Parameters
layout ConstraintLayout

Returns
View[]

init

protected void init (AttributeSet attrs)

Parameters
attrs AttributeSet