我是BottomSheet的新手,并一直在尝试阅读一些教程并遵循,但是,当我加载我的应用程序时,底部表格会完整显示,而不只是像我设置的那样偷看。
我只希望显示EditText,然后当我开始键入内容时,其余的将弹出。我很确定我知道如何使用textWatcher进行第二部分的操作,但是我不能一开始就将底页部分隐藏起来,并且可以完全显示出来。
这是我的工作表布局:
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="24dp"
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"
app:behavior_hideable="false"
app:behavior_peekHeight="64dp"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:inputType="textCapSentences"
android:ems="10"
android:id="@+id/question_bottom_sheet_input"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:background="@drawable/gray_form_field"
android:paddingStart="16dp"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:textColor="@color/gray700"
android:textSize="15sp"
android:fontFamily="@font/roboto"
android:hint="@string/what_would_you_like_to_know"/>
<androidx.recyclerview.widget.RecyclerView
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:id="@+id/question_bottom_sheet_recycler"
app:layout_constraintTop_toBottomOf="@+id/question_bottom_sheet_message"
android:layout_marginTop="24dp"
app:layout_constraintBottom_toTopOf="@+id/question_bottom_sheet_ask_button"
android:layout_marginBottom="24dp"/>
<TextView
android:text="@string/ask"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/question_bottom_sheet_ask_button"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:textSize="15sp"
android:textColor="@color/gray700"
android:fontFamily="@font/roboto_bold"/>
<TextView
android:text="@string/do_any_of_these_posts_solve_your_problem"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/question_bottom_sheet_message"
android:layout_marginTop="24dp"
app:layout_constraintTop_toBottomOf="@+id/question_bottom_sheet_input"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:textColor="@color/gray500"
android:fontFamily="@font/roboto_medium"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
然后我只使用include将其放入所需的片段中。
<include layout="@layout/question_bottom_sheet"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:layout_width="0dp"
android:layout_height="wrap_content"/>