1

我想在片段(nawDrawer 的片段)中制作 bottomSheet。我使用 pre L target API 中的谷歌指南做到了这一点。

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View v = inflater.inflate(R.layout.fragment_fragment_help, container, false);
    View bottomSheet = v.findViewById(R.id.bottom_shit);
    mBottomSheetBehavior = BottomSheetBehavior.from(bottomSheet);
    final LinearLayout test = (LinearLayout) v.findViewById(R.id.calls);
    test.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {


            mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
        }


    });
    mBottomSheetBehavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
        @Override
        public void onStateChanged(@NonNull View bottomSheet, int newState) {
            // React to state change
        }

        @Override
        public void onSlide(@NonNull View bottomSheet, float slideOffset) {
            // React to dragging events
        }
    });

    return v;
}

结果,我可以在展开时看到部分片段布局bottomSheet

一些聪明的人告诉我在bottomSheet布局中设置背景颜色 - 没办法。布局变得彩色,但我可以看到那些片段。

我做错了什么?

4

0 回答 0