1

Есть вертикальный linear layout. В нем должно быть два cardview, которые должны занимать половину layout. Как это сделать. Сейчас получается так, что размеры cardview меняются в зависимости от загружаемой картинки.

<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>

1 ответ 1

1

Замените android:layout_height="wrap_content" в CardView на

android:layout_height="0dp"

так вес android:layout_weight="1" будет работать как вам нужно.

Ваш ответ

Нажимая на кнопку «Отправить ответ», вы соглашаетесь с нашими пользовательским соглашением, политикой конфиденциальности и политикой о куки

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.