我有一个Recyclerview和它下面的按钮。在初始状态下,一切看起来都很好:recyclerview为按钮腾出空间,我可以向下滚动到列表的末尾,最后一项不会被按钮隐藏。当我选择其中一个项目时,一个按钮变得不可见,其他按钮变得可见。
当按钮更改其可见性时,recyclerview会填充父级,因此部分内容将隐藏在最近出现的按钮下。
我希望recyclerview会缩小它的高度,为按钮留出一些空间。
我已尝试将其应用于swiperefreshlayout:
android:layout_height="0dp"
android:layout_weight="1"
但是现在,当第一个按钮隐藏而其他按钮出现时,recyclerview就会消失。
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_height="match_parent"
android:layout_width="match_parent">
<include
layout="@layout/toolbar_actionbar" />
<TextView
android:gravity="center"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_centerInParent="true"
android:layout_gravity="center|center"
android:maxLines="10"
android:textSize="20dp"
local:MvxBind="Text EmptyMessage;Visibility Visibility(ShowEmptyMessage)" />
<MvvmCross.Droid.Support.V4.MvxSwipeRefreshLayout
android:id="@+id/timeslotsSwipeRefresh"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/getTimeslotButton"
android:layout_below="@+id/appbar"
local:layout_behavior="@string/appbar_scrolling_view_behavior"
local:MvxBind="Refreshing IsRefreshingTimeslots; RefreshCommand RefreshTimeslotsCommand">
<!-- Here is my recycler view -->
<MvxRecyclerView
android:id="@+id/MyTimeslotsRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
local:MvxBind="ItemsSource Timeslots;Visibility Visibility(ShowList)"
local:MvxItemTemplate="@layout/item_my_timeslot" />
</MvvmCross.Droid.Support.V4.MvxSwipeRefreshLayout>
<!-- Here is my disappearing button -->
<android.support.v7.widget.AppCompatButton
android:id="@+id/getTimeslotButton"
android:text="Получить таймслоты"
android:theme="@style/ButtonPrimary"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_alignParentBottom="true"
local:MvxBind="Click GetTimeslotsCommand; Visibility InvertedVisibility(IsEditModeEnabled)" />
<!-- Here are my appearing buttons.
I placed it inside of a relativelayout
to make a single visibility data binding -->
<RelativeLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_alignParentBottom="true"
local:MvxBind="Visibility Visibility(IsEditModeEnabled)">
<android.support.v7.widget.AppCompatButton
android:id="@+id/copyToSmsButton"
android:text="Отправить по SMS"
android:theme="@style/ButtonPrimary"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_marginBottom="0dp"
android:layout_alignParentLeft="true"/>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_below="@id/copyToSmsButton">
<android.support.v7.widget.AppCompatButton
android:id="@+id/deleteTimeslotButton"
android:text="Удалить"
android:theme="@style/ButtonSecondary.Red"
android:layout_marginTop="0dp"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"/>
<android.support.v7.widget.AppCompatButton
android:id="@+id/moveTimeslotButton"
android:text="Перенести"
android:theme="@style/ButtonSecondary"
android:layout_marginTop="0dp"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"/>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>