Я работаю на макете с cardview, флажок и кнопку с исходной структурой, как показано на первом изображении:Первый вид в RelativeLayout расширить, чтобы заполнить оставшееся пространство
В этом case listview не показывается до тех пор, пока пользователь не нажмет на изображение внутри карты, поэтому, когда это произойдет, структура с пролонгацией похожа на второе изображение
Однако, поскольку список на самом деле находится внутри фрагмента, я не могу выполнить простую компоновку потому что wrap_content a d match_parent для cardview дает мне следующий результат
И как вы можете увидеть cardview перекрывает кнопку и флажок выходит за пределы экрана
Сейчас это мой макет:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white">
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/card"
android:layout_marginTop="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_alignParentTop="true"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
>
<ImageButton
android:layout_width="@dimen/event_invitation_expand_icon"
android:layout_height="@dimen/event_invitation_expand_icon"
android:id="@+id/shrink"
android:src="@drawable/ic_shrink"
android:background="@android:color/transparent"
android:scaleType="fitCenter"
android:layout_gravity="center_vertical"
android:layout_marginRight="5dp"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/shrink"
android:layout_marginTop="5dp"
android:id="@+id/list">
<fragment
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:name="ListFragment"
tools:layout="@layout/fragment_list"/>
</RelativeLayout>
</RelativeLayout>
</android.support.v7.widget.CardView>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/checkBox"
android:layout_marginTop="20dp"
android:layout_below="@+id/card"/>
<Space
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/button"
android:layout_below="@+id/checkBox"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/button"
android:layout_alignParentBottom="true"
style="@android:style/Widget.DeviceDefault.Button.Borderless"
/>
Я надеюсь, что вы можете помочь мне установить максимальную высоту зрения карты, чтобы остановить рост, когда й пробел заполнен.
Я также постарался установить флажок всегда в верхней части нижней части экрана и в виде карты, чтобы заполнить оставшееся пространство, и хотя он дает мне правильную структуру при расширении списка, это не работает для списка, скрытого с Картограф заполняет пространство ничем.
Update
Как предложил я попытался изменить корневой макет в LinearLayout используя вес, однако, я получил тот же результат, как и раньше, и если я изменить вес cardview к 1 и флажок на 0 Я могу получить желаемый макет для расширенного списка, но не для скрытого случая.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:orientation="vertical">
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/card"
android:layout_marginTop="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="0">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="5dp"
>
<ImageButton
android:layout_width="@dimen/event_invitation_expand_icon"
android:layout_height="@dimen/event_invitation_expand_icon"
android:id="@+id/shrink"
android:src="@drawable/ic_shrink"
android:background="@android:color/transparent"
android:scaleType="fitCenter"
android:layout_gravity="center_vertical"
android:layout_marginRight="5dp"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/shrink"
android:layout_marginTop="5dp"
android:id="@+id/list">
<fragment
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:name="ListFragment"
tools:layout="@layout/fragment_list"/>
</RelativeLayout>
</android.support.v7.widget.CardView>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/check"
android:id="@+id/check"
android:layout_marginTop="20dp"
android:layout_below="@+id/card"
/>
</LinearLayout>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/button"
android:textStyle="bold"
android:textColor="@android:color/white"
/>
Thnk вы, я дам ему попробовать – ElAwDk
Я попытался с LinearLayout, но все же получил ту же проблему – ElAwDk
@ElAwDk вы использовали вес в childs и установили их высоту до 0? –