Skip to content
gonodono edited this page Jul 21, 2024 · 4 revisions

All of the Examples use the pertinent framework's ConstraintLayout component, and its circular positioning functionality.

Screenshots of the two example formats previewed in Android Studio.

The View versions use the HexagonDrawable class as the children's backgrounds to draw the actual shape. A <drawable> is created in resources so we can use it with the android:background attribute. It's been designed to take a simple tint using android:backgroundTint so we can set different colors in the layout, as well. It's also been set up to recognize and process a custom attribute that allows specifying the hexagon's orientation in the resource XML.

The Compose version's analog to the Drawable is the Hexagon Composable. It uses the same proportional spacing for vertex calculations as HexagonDrawable, and integrates with Compose's Shape mechanism, so it actually has several more visual options available than the Drawable does at the moment. It has a @Composable content parameter as well, so it actually substitutes for both the child View and its Drawable in the other version.

The complete code is contained within the demo's examples subpackage, grouped by two different formats: Shield and Grid.


Next: Shield →

Clone this wiki locally