There is a vertical linear layout. It should have two cardviews that should occupy half the layout. How to do it. Now it turns out that the size of the cardview varies depending on the loaded image.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:card_view="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".CompanyMenuFragment" android:orientation="vertical"> <!-- TODO: Update blank fragment layout --> <android.support.v7.widget.CardView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" card_view:cardUseCompatPadding="true" card_view:cardCornerRadius="8dp"> <ImageView android:id="@+id/menu_image" android:layout_width="match_parent" android:layout_height="match_parent" android:adjustViewBounds="true" android:scaleType="fitCenter" /> </android.support.v7.widget.CardView> <android.support.v7.widget.CardView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" card_view:cardUseCompatPadding="true" card_view:cardCornerRadius="8dp"> <ImageView android:id="@+id/menu_image1" android:layout_width="match_parent" android:layout_height="match_parent" android:adjustViewBounds="true" android:scaleType="fitCenter"/> </android.support.v7.widget.CardView> </LinearLayout>