我想在片段(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
布局中设置背景颜色 - 没办法。布局变得有色,但我可以看到那些碎片。
我做错了什么?