I've created my own ViewGroup with the aim to evenly distribute 4 elements in its area.
The ViewGroup itself is set to match_parent in both width and height with a TextView above it:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/relativeLayout2"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/relativeLayout"
android:paddingBottom="16"
android:paddingLeft="16"
android:paddingRight="16"
android:paddingTop="16">
<TextView
android:id="@+id/title_actions"
style="@style/h2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/title_dashboard"
android:textColor="@color/colorAccent" />
<app.xenon.sync.layout.dashboard
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/title_actions"
android:layout_marginTop="16dp">
<!-- 4 elements here -->
</app.xenon.sync.layout.dashboard>
</RelativeLayout>
The question at hand is how to get the width of the ViewGroup itself from its own class to then distribute the children. I would assume that this would be done in the onMeasure method, yet after digging through here and the Javadoc I wasn't able to find anything that could help me.
So this is why I found you!