I want to have 5 imageviews, one next to each other (horizontally) and each imageview should have the width of 1/5 the screen. Instead of measuring and setting widths inside the activity, I achieved the result using linear layouts this way:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="vertical">
<com.davidbalas.brawlstarsinfo.CustomTextView
android:id="@+id/nameTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:textColor="@android:color/white"
android:textSize="28sp"
android:textStyle="bold"
app:fontName="supercell.ttf" />
<com.davidbalas.brawlstarsinfo.CustomTextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@android:color/white"
android:textSize="12sp"
android:textStyle="bold"
app:fontName="supercell.ttf" />
<com.davidbalas.brawlstarsinfo.CustomTextView
android:id="@+id/top5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="@string/top_5_brawlers_for"
android:textColor="@android:color/white"
android:textSize="22sp"
android:textStyle="bold"
app:fontName="supercell.ttf" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal">
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:contentDescription="@string/top_5_brawlers_for"
android:src="@drawable/barley" />
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:contentDescription="@string/top_5_brawlers_for"
android:src="@drawable/barley" />
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:contentDescription="@string/top_5_brawlers_for"
android:src="@drawable/barley" />
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:contentDescription="@string/top_5_brawlers_for"
android:src="@drawable/barley" />
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:contentDescription="@string/top_5_brawlers_for"
android:src="@drawable/barley" />
</LinearLayout>
</LinearLayout>
However, I get an error nested weights are bad for performance. What is a good, other way, to achieve what I am looking for?