簡體   English   中英

片段內部的底頁對話框

[英]Bottom Sheet Dialog from inside a fragment

我目前正在嘗試在我的應用程序中實現bottomSheetDialog。 我的主要活動由一個viewpager,一個頂部欄和一個底部導航欄組成,我用它們在片段之間進行切換。 在其中一個片段中,我試圖設置一個必須出現在Main Activity頂部的模式按鈕工作表對話框

    titleDemo = view.findViewById(R.id.title1);

    titleDemo.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(getContext());
            View parentView = getLayoutInflater().inflate(R.layout.dialog, null);
            bottomSheetDialog.setContentView(parentView);
            bottomSheetDialog.show();
        }
    });

當我單擊時,活動行為正確,其顏色逐漸消失,但什么也沒有顯示。 在我的測試中,我使用了帶有一些隨機背景色的簡單布局。

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/lightCyan">

</LinearLayout>

我覺得我在弄亂意見,但我不明白如何解決這個問題。

謝謝

您需要添加這些行

    app:behavior_hideable="true"
    app:behavior_peekHeight="120dp"
    app:layout_behavior="android.support.design.widget.BottomSheetBehavior"

在您的LinearLayout

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM