全屏底部页面,顶部有关闭(X)按钮

时间:2016-07-20 13:08:15

标签: android android-design-library bottom-sheet

我正在尝试从google设计库中实现底部工作表。单击按钮应打开覆盖整个活动窗口的底部工作表。就像我们通过Gmail在Inbox中打开电子邮件一样。但是,它应该从底部打开并向下滑动以消除。

按钮单击应打开底部工作表,向下滑动或向左滑动关闭(X)按钮应关闭工作表。

我已经设置了这样的东西:

<android.support.design.widget.CoordinatorLayout
    .. >

    <android.support.v4.widget.NestedScrollView
        android:id="@+id/bottom_sheet"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_behavior="@string/bottom_sheet_behavior">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Hello Bottom Sheet !!" />

    </android.support.v4.widget.NestedScrollView>

    <include layout="@layout/content_my_activity" />

</android.support.design.widget.CoordinatorLayout>

我正在这样初衷:

    mBottomSheet = (NestedScrollView) findViewById(R.id.bottom_sheet);
    mBottomSheetBehavior = BottomSheetBehavior.from(mBottomSheet);
    mButton = (Button) findViewById(R.id.bottom_sheet_button);
    mButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
        }
    });

但是,当我点击一个按钮时,文本就会显示在底部。重叠默认的现有内容。底部背后没有黑色透明色调。

点击按钮后如何全屏显示?

我在这里没有使用片段的原因是,我有一些(很多)变量,取决于底层的内容。因此,如果我通过片段显示底部表格,我需要来回传递和接收所有数据。为了避免这种情况,我希望它成为活动的一部分。

有什么方法可以实现这个目标吗?谢谢你的帮助。

2 个答案:

答案 0 :(得分:0)

<form  method='POST' action='update.PHP' enctype='multipart/form-data'>

试试这段代码........

答案 1 :(得分:-1)

当你点击按钮时,你可以认为这个动作就像你的NestedScrollView容器一样可见,所以它会像你在params写的那样发生

android:layout_width="match_parent"
android:layout_height="wrap_content"

如果您希望它采用完整的父高度,请使用

android:layout_height="match_parent"

如果要谈论像片段一样的阴影背景,你可以欺骗你可以为NestedScrollView设置背景alpha颜色

android:background="#64000000"

但这是一个黑客,你可以使用片段,只是从活动发送所有信息,反之亦然