You can use the same method posted here about making the background transparent and change transparent to color.
Create onCreateView
and inside add the following line: getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(Color.YELLOW));
Change Color.YELLOW
to the background color that you want.
Full example:
public class ClassName extends AppCompatDialogFragment {
...
...
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(Color.YELLOW));
return super.onCreateView(inflater, container, savedInstanceState);
}
}
If you want color from colors resources use:
getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(getContext().getColor(R.color.colorPrimary)));
Were colorPrimary
is color resources name.