android – Correct way to make a custom material dialog with appCompat 23+-ThrowExceptions

Exception or error:

Ok I’m really confused here on how to make a custom dialog properly using the latest appcompat v23.0.1
Here is a couple of ways

First way:

public class AddTipDialogFrag extends DialogFragment
 public Dialog onCreateDialog(Bundle savedInstanceState)
        int title = getArguments().getInt("title");
        AppCompatDialog dialogCompat = new AppCompatDialog(getActivity(),;
        dialogCompat.setTitle(title); //doesn't work btw
        return dialogCompat;

2nd way:

public class AddTipDialogFrag extends AppCompatDialogFragment
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        View view = inflater.inflate(R.layout.add_tip_fragment,container, false);
        int title = getArguments().getInt("title");
        return view;

Both ways seem to produce the same result. Personally I prefer the 1st way however there is an issue with ripple effect where it gets cut out when the custem view border ends, as you can see on the picture below.

ripple effect fail

Is this a bug? (It must be!) Can I fix it or should I just convert to the 2nd way? (Which works fine with the ripple effect). What is the best approach between those 2 ways considering most material dialog libraries are using the first way?

EDIT: the ripple glitch on the first way doesn’t seem to occur anymore so I’m still not sure which is the right way of those two.

How to solve:

Second approch seems better as AppCompatDialogFragment extends DialogFragment and does all the heavy lifting for you. Also it looks cleaner with abstraction of unnecessary details (inline with OOP).

Also gives desired effact 😉


The Second Approach is better as because it is a special version of DialogFragment which uses an AppCompatDialog in place of a platform-styled dialog.
The AppCompatDialogFragment is the sub class of DialogFragment and will inherit all the properties of the DialogFragment.

Leave a Reply

Your email address will not be published. Required fields are marked *