如何解决拖动具有3级状态的BottomSheetDialogFragment时显示/隐藏视图
我有一种情况,如果用户单击“是”或将底部的表拖到顶部,BottomSheetDialogFragment将从下面弹出并要求修改页面;动画会消失第一个视图(cl_collapsed_container),动画也会出现新的视图(cl_expanded_container)。
我尝试了很多组合,但无法完成。
这是我的xml;
import { cat,dog } from './animals';
const housePets = { cat,dog };
我的代码:
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/rl_customize_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:behavior_hideable="false"
app:behavior_peekHeight="300dp"
app:layout_behavior="@string/bottom_sheet_behavior">
<TextView
android:id="@+id/tv_headline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/margin_large"
android:text="@string/customize_your_feed"
android:textColor="@color/black" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_collapsed_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/tv_headline">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/btn_customize"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/customize"
app:layout_constraintTop_toBottomOf="@id/tv_desc" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_expanded_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_below="@id/cl_collapsed_container"
android:visibility="gone"
>
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/button10"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
android:text="Button 10" />
<androidx.appcompat.widget.AppCompatButton
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="@+id/button10"
android:text="Button 9"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
我无法将页面拖到顶部(我需要屏幕的90%作为最大高度), 此代码将不遵守窥视高度和可隐藏属性。不管我添加到窥视高度的哪个值,它都使用一半的屏幕并显示折叠视图的一半视图。 如果我以编程方式将状态设置为展开或折叠,也不会调用onSlide回调。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。