This library is a set of simple wrapper classes that are aimed to help you easily create fancy material dialogs.
Switch branches/tags
Nothing to show
Clone or download


Android Arsenal

This library is a set of simple wrapper classes that are aimed to help you easily create fancy material dialogs.



Add this into your dependencies block.

compile 'com.yarolegovich:lovely-dialog:1.1.0'



As advised in Effective Java

Favor composition over inheritance.

LovelyDialog doesn't subclass any Dialog related classes, it is just a lightweight extensible wrapper for Dialog and manipulations with custom view. If you would like to improve something - pull requests are appreciated.

Sample project that shows how to work with different dialogs and handle screen rotation is available under the sample module.

Dialog types

Each dialog has colored top, icon, title and message + its own features. There are 6 types of dialogs available:

Access to inner View objects

Starting from a version 1.1.0 of the library, you have an access to dialog's inner View objects via methods whose names are prefixed with configure. For example:

      .configureView(rootView -> /* you can find any view here, view ids are prefixed with ld_ */)
      .configureTitleView(title -> title.setTextSize(customTextSize))
      .configureMessageView(message -> message.getPaint().setShader(customShader))

I advise not to overuse this feature. If you are doing it, think of creating a custom Dialog subclass. LovelyTextInpuDialog exposes its EditText via configureEditText.


You can set positive, negative and neutral button here. Listeners can be set individually for each button, one for all three or not set at all (onClick on any button dialog will be just dismissed).

new LovelyStandardDialog(this, LovelyStandardDialog.ButtonLayout.VERTICAL)
      .setPositiveButton(android.R.string.ok, new View.OnClickListener() {
          public void onClick(View v) {
              Toast.makeText(context, "positive clicked", Toast.LENGTH_SHORT).show();
      .setNegativeButton(, null)


Dialog for displaying information to the user, content is scrollable. There is an option to show Don't show again checkbox. If checked - dialog won't be called next time. This can be useful when showing some tutorials, for example.

new LovelyInfoDialog(this)
      //This will add Don't show again checkbox to the dialog. You can pass any ID as argument


Here you can use either single choice or multi choice dialogs. In case of multi choice dialog - Confirm button will appear. You can pass items as array, List (.toString() will be used to display them as simple text items) or provide your custom adapter.

Single choice
ArrayAdapter<DonationOption> adapter = new DonationAdapter(this, loadDonationOptions());
new LovelyChoiceDialog(this)
      .setItems(adapter, new LovelyChoiceDialog.OnItemSelectedListener<DonationOption>() {
           public void onItemSelected(int position, DonationOption item) {
               Toast.makeText(context, getString(R.string.you_donated, item.amount),Toast.LENGTH_SHORT).show();
Multi choice
String[] items = getResources().getStringArray(;
new LovelyChoiceDialog(this,
      .setItemsMultiChoice(items, new LovelyChoiceDialog.OnItemsSelectedListener<String>() {
          public void onItemsSelected(List<Integer> positions, List<String> items) {
                      getString(R.string.you_ordered, TextUtils.join("\n", items)),


Dialog with EditText and Confirm button. You can set TextFilter object to specify acceptable input.

new LovelyTextInputDialog(this,
      .setInputFilter(R.string.text_input_error_message, new LovelyTextInputDialog.TextFilter() {
          public boolean check(String text) {
              return text.matches("\\w+");
      .setConfirmButton(android.R.string.ok, new LovelyTextInputDialog.OnTextInputConfirmListener() {
           public void onTextInputConfirmed(String text) {
              Toast.makeText(MainActivity.this, text, Toast.LENGTH_SHORT).show();


Dialog with standard Android ProgressBar. Not cancelable by default.

new LovelyProgressDialog(this)


Here you can pass your own view to be displayed. Title, message, color header and icon will still be available for use. You can provide configurators, click listeners and instance state save handlers.

new LovelyCustomDialog(this)
      .configureView(/* ... */)
      .setListener(, /* ... */)
      .setInstanceStateManager(/* ... */)

Configuration changes

There is a class LovelySaveStateHandler that helps you to persist information about which dialog was shown (if any) between configuration changes. Each dialog (except LovelyCustomDialog) knows how to save and restore its state. Refer to sample project for examples of how to deal with configuration changes.

Tinting controls

If you want CheckBoxes, EditTexts etc. to be of different color - what you need is to define theme in xml

<style name="TintTheme" parent="Theme.AppCompat.Light.Dialog.Alert">
      <item name="colorAccent">@color/colorToTintWith</item>

and pass it as a second argument to dialog's constructor

new LovelyTextInputDialog(this,

Standard dialogs compatibility

If you don't want to rewrite your


implementations, you can simply use


to pass it to one of the


or the like.


Copyright 2016 Yaroslav Shevchuk

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and
limitations under the License.