1

我尝试使用包含片段容器的圆角创建 BottomSheetDialogFragment。我做了正确的drawable并应用于这个片段的xml。代码:

public class ContainerFragment extends BottomSheetDialogFragment {

@Override
public void setupDialog(Dialog dialog, int style) {
    View view = View.inflate(getContext(), R.layout.fragment_delivery_container, null);
    dialog.setContentView(view);
    // тут делаю так, чтобы фон под удалёнными краями из-за скругления был прозрачным
    ((View) view.getParent()).setBackgroundColor(getResources().getColor(android.R.color.transparent));

/*getChildFragmentManager()
            .beginTransaction()
            .add(R.id.container, ProvidersFragment.createInstance(), "TASGGGG")
            .commit();*/
}

@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    BottomSheetDialog bDialog = (BottomSheetDialog) super.onCreateDialog(savedInstanceState);
    ...
    return bDialog;
}

/*    @Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = View.inflate(getContext(), R.layout.fragment_delivery_container, null);
    getChildFragmentManager()
            .beginTransaction()
            .add(R.id.container, ProvidersFragment.createInstance(), "TASGGGG")
            .commit();
    return view;
}*/

....
}

在当前的代码实现中,一切都很好(圆角),只有片段事务被注释掉了。如果我取消注释,它将引发“片段没有视图”的错误。因此,如果我取消注释 onCreateView,则此视图的边缘会出现,我对此无能为力

4

0 回答 0