我正在尝试从谷歌设计库中实现一个底页。单击按钮应打开覆盖整个活动窗口的底部工作表。就像我们在 Inbox by Gmail 中打开电子邮件一样。但是,它应该从底部打开并向下滑动以关闭。
按钮单击应打开底部工作表,向下滑动或左上角关闭 (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);
}
});
但是,当我单击一个按钮时,文本只会出现在底部。重叠默认的现有内容。并且底片后面没有黑色透明色调。
单击按钮时如何使其全屏显示?
我在这里不使用片段的原因是,我有一些(许多)变量,具体取决于底部表格的内容。所以,如果我通过片段显示底部表,我需要来回传递和接收所有数据。为了避免这种情况,我希望它成为活动的一部分。
有什么办法可以做到这一点?谢谢你的帮助。