约束布局中0dp的对话框布局高度不起作用

时间:2018-12-25 06:10:35

标签: android android-constraintlayout bottom-sheet

当前使用约束布局创建对话框并放置类似这样的视图,但是0dp的视图高度不起作用。

在这里看不到recyclerview。

<?xml version="1.0" encoding="utf-8"?>
<layout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:bind="http://schemas.android.com/tools">
    <data>
        <variable
            name="passengerSeatViewModel"
            type="PassengerSeatViewModel" />
        <variable
            name="seatSelectionViewModel"
            type="SeatSelectionViewModel" />
    </data>
    <android.support.constraint.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/colorWhite">
        <android.support.constraint.Guideline
            android:id="@+id/guideline_left"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            app:layout_constraintGuide_begin="@dimen/_20dp" />
        <android.support.constraint.Guideline
            android:id="@+id/guideline_right"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            app:layout_constraintGuide_end="@dimen/_20dp" />
        <include
            android:id="@+id/header"
            layout="@layout/dialog_header"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            app:layout_constraintLeft_toRightOf="@+id/guideline_left"
            app:layout_constraintRight_toLeftOf="@+id/guideline_right"
            bind:header="@{@string/text_seat_selected_for}"
            bind:onCancelClick="@{passengerSeatViewModel}" />
        <android.support.v7.widget.AppCompatTextView
            android:id="@+id/tv_segment"
            style="@style/TextStyle_L_Black"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="@dimen/_5dp"
            android:layout_marginLeft="@dimen/_5dp"
            android:drawableEnd="@drawable/green_filled_tick"
            android:drawableRight="@drawable/green_filled_tick"
            android:drawablePadding="@dimen/_5dp"
            android:gravity="center"
            android:text="@{seatSelectionViewModel.getSelectedSegment()}"
            app:layout_constraintLeft_toRightOf="@+id/guideline_left"
            app:layout_constraintTop_toBottomOf="@+id/header" />
        <android.support.v7.widget.RecyclerView
            android:id="@+id/rv_passengers"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_marginTop="@dimen/_3dp"
            app:layout_constraintBottom_toTopOf="@+id/barrier_select_seats"
            app:layout_constraintLeft_toLeftOf="@+id/guideline_left"
            app:layout_constraintRight_toRightOf="@+id/guideline_right"
            app:layout_constraintTop_toBottomOf="@+id/tv_segment"
            bind:data="@{seatSelectionViewModel.passengerAdapterViewModel}"
            bind:passengerViewModel="@{passengerSeatViewModel}" />
        <android.support.constraint.Group
            android:id="@+id/group_copy"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:visibility="gone"
            app:constraint_referenced_ids="btn_copy_seat,tv_or,seperator_left,seperator_right" />
        <android.support.v7.widget.AppCompatButton
            android:id="@+id/btn_copy_seat"
            style="@style/AppBtnStyle_Disable"
            android:layout_width="0dp"
            android:text="@string/text_copy_same_seat"
            app:layout_constraintLeft_toLeftOf="@+id/guideline_left"
            app:layout_constraintRight_toRightOf="@+id/guideline_right"
            app:layout_constraintTop_toBottomOf="@+id/rv_passengers" />
        <android.support.v7.widget.AppCompatTextView
            android:id="@+id/tv_or"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/_20dp"
            android:paddingLeft="@dimen/_23dp"
            android:paddingRight="@dimen/_23dp"
            android:text="@string/or"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/btn_copy_seat" />
        <View
            android:id="@+id/seperator_left"
            android:layout_width="0dp"
            android:layout_height="@dimen/_1dp"
            android:background="@color/colorDividerSearch"
            app:layout_constraintBottom_toBottomOf="@+id/tv_or"
            app:layout_constraintLeft_toRightOf="@+id/guideline_left"
            app:layout_constraintRight_toLeftOf="@+id/tv_or"
            app:layout_constraintTop_toTopOf="@+id/tv_or" />
        <View
            android:id="@+id/seperator_right"
            android:layout_width="0dp"
            android:layout_height="@dimen/_1dp"
            android:background="@color/colorDividerSearch"
            app:layout_constraintBottom_toBottomOf="@+id/tv_or"
            app:layout_constraintLeft_toRightOf="@+id/tv_or"
            app:layout_constraintRight_toLeftOf="@+id/guideline_right"
            app:layout_constraintTop_toTopOf="@+id/tv_or" />
        <android.support.constraint.Barrier
            android:id="@+id/barrier_seats"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:barrierDirection="bottom"
            app:constraint_referenced_ids="tv_or,rv_passengers" />
        <android.support.constraint.Barrier
            android:id="@+id/barrier_select_seats"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:barrierDirection="top"
            app:constraint_referenced_ids="tv_or,btn_select_seat" />
        <android.support.v7.widget.AppCompatButton
            android:id="@+id/btn_select_seat"
            style="@style/AppBtnStyleBlueBorderless"
            android:layout_width="0dp"
            android:layout_marginTop="@dimen/_16dp"
            android:text="@string/text_select_seat_for"
            app:layout_constraintBottom_toTopOf="@+id/footer_space"
            app:layout_constraintLeft_toLeftOf="@+id/guideline_left"
            app:layout_constraintRight_toRightOf="@+id/guideline_right" />
        <Space
            android:id="@+id/footer_space"
            android:layout_width="0dp"
            android:layout_height="@dimen/_22dp"
            app:layout_constraintBottom_toBottomOf="parent" />
    </android.support.constraint.ConstraintLayout>
</layout>

注意:

  • 1)需要在页脚及其上方的其他内容上固定按钮。以上 部分将具有换行内容的高度。

    2)内容不在底部工作表内滚动

1 个答案:

答案 0 :(得分:0)

在recyclerView中使用app:layout_constraintHeight_default="wrap"