Search code examples
javaandroidandroid-layoutandroid-alertdialogdialogfragment

How to create dialog with uneven edges


I need to create a dialog with uneven edges. like that

I tried to set background from drawable resources with that backgroung image.

public class Dialog extends DialogFragment {
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.dialog, null, false);

    view.setBackgroundResource(R.drawable.aaa);

    return view;
}

But the dialog was with a white background.

I'm looking for a solution easier that already exist.


Solution

  • Add the following code inside the Dialog class

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setStyle(STYLE_NO_TITLE, android.R.style.Theme_Translucent_NoTitleBar);
    }