首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >禁止BottomSheetDialogFragment显示

禁止BottomSheetDialogFragment显示
EN

Stack Overflow用户
提问于 2020-06-09 11:10:23
回答 1查看 260关注 0票数 0

我有两个底部工作表对话框片段布局,我已经包括在一个CoordinatorLayoutCoordinatorLayout有一个RecyclerView,其项在单击时显示一个底部工作表对话框片段。第一个底部页对话框片段用于更新回收器视图中的项目。第二底部工作表对话框片段用于执行项目的支付。问题是,当我显示第二底页付款,并错误地点击项目,第一底页低于第二。在显示第二个底部工作表时,我是否可以将第一个底部工作表对话框设置为禁用,或者将可见性设置为“在按钮中消失”?

这是我的XML

代码语言:javascript
复制
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".Activities.CartActivity">


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <com.google.android.material.appbar.AppBarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:theme="@style/AppTheme.AppBarOverlay">

            <androidx.appcompat.widget.Toolbar
                android:id="@+id/cart_tool_bar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="?attr/colorPrimary"
                app:popupTheme="@style/AppTheme.PopupOverlay"/>

        </com.google.android.material.appbar.AppBarLayout>

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/colorWhiteShade">

            <androidx.recyclerview.widget.RecyclerView
                android:id="@+id/cart_recycler_view"
                android:layout_width="match_parent"
                android:layout_height="match_parent"/>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:background="@color/colorWhiteDarker"
                android:padding="5dp"
                android:orientation="vertical">

                <androidx.cardview.widget.CardView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    app:cardCornerRadius="5dp"
                    android:layout_margin="2dp"
                    android:padding="5dp">

                    <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:padding="5dp">

                        <TextView
                            android:id="@+id/tv_sub_total"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="@string/sub_total"
                            android:textSize="20sp"
                            style="@style/TextAppearance.AppCompat.Large"/>

                        <TextView
                            android:id="@+id/sub_total"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="@string/sub_total"
                            style="@style/TextAppearance.AppCompat.Body1"
                            android:textStyle="bold"
                            android:layout_alignParentEnd="true"
                            android:textSize="17sp"
                            />

                        <View
                            android:id="@+id/view"
                            android:layout_centerHorizontal="true"
                            android:layout_width="350dp"
                            android:layout_height="1dp"
                            android:background="@color/colorBlack20"
                            android:layout_margin="2dp"
                            android:layout_below="@id/sub_total"/>

                        <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_below="@+id/view"
                            android:layout_margin="2dp"
                            android:padding="2dp"
                            android:gravity="center"
                            android:orientation="horizontal">

                            <Button
                                android:id="@+id/btn_post_payment"
                                android:layout_width="wrap_content"
                                android:layout_height="35dp"
                                android:drawableStart="@drawable/pay_icon"
                                android:text="@string/pay"
                                android:background="@drawable/ripple"
                                android:layout_marginStart="2dp"
                                android:layout_marginEnd="2dp"
                                android:textColor="@android:color/white"
                                android:padding="5dp"
                                style="?attr/borderlessButtonStyle"
                                android:textAllCaps="false"/>

                        </LinearLayout>

                    </RelativeLayout>

                </androidx.cardview.widget.CardView>

            </LinearLayout>

        </RelativeLayout>

    </LinearLayout>

    <!-- Always include layout below all the other layouts -->
    <include layout="@layout/layout_cart_bottom_sheet"/>

    <!-- Always include layout below all the other layouts -->
    <include layout="@layout/layout_post_payment"/>


</androidx.coordinatorlayout.widget.CoordinatorLayout>

我可能喜欢的另一个实现是,如果第一个对话框可以检查第二个对话框是否已经显示,并阻止它再次显示。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-06-09 11:18:36

您可以将可见性设置为:

<include layout="@layout/layout_cart_bottom_sheet" visibility="gone"/>

或将布局的id设置为:

<include android:id="@+id/cart_bottomsheet" layout="@layout/layout_cart_bottom_sheet">

并使用findViewByIdsetVisibility切换可见性。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62281229

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档