Good day. You need to make two ImageViews split the screen in half width and have a square shape (the side of the square is half the width). I coped with the first part by describing the following markup:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent" android:weightSum="100"> <ImageView android:layout_width="0dp" android:layout_height="50dp" android:layout_weight="50" android:background="#0F0"/> <ImageView android:layout_width="0dp" android:layout_height="50dp" android:layout_weight="50" android:background="#FF0"/> </LinearLayout> 

Now the most interesting thing is how to make it so that the height becomes equal to the width?

    1 answer 1

    Here is the answer. You need to override the onMeasure method in the class inherited from imageView and connect it to the markup. And it is enough to make one such class, beauty. Here's an example https://github.com/chiuki/android-square-view/tree/master/src/com/sqisland/android/square_view