0

I have searched for an answer to this question but none of the answers helped me.

The problem is that I have a DialogFragment that is displayed when a user add a widget (as part of the WidgetConfig). It looks like this:

enter image description here

The dialog is created like this;

Calling activity:

public class AppWidgetConfigure extends Activity {

    private void setUp(){

        //Config widget code removed 

        DialogFragment dialog = new ChooserDialog();
        dialog.show(getFragmentManager(), "dialog");
    }
}

the DialogFragment:

public class ChooserDialog extends DialogFragment {

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {

        choices = getResources().getStringArray(R.array.choices);
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());       
        builder.setTitle(getResources().getString(R.string.widget_dialog_chooser_title));
        builder.setPositiveButton(getResources().getString(R.string.widget_dialog_chooser_posBtn), this);
        builder.setNegativeButton(getResources().getString(R.string.widget_dialog_chooser_negBtn), this);   
        builder.setSingleChoiceItems(choices, -1, this);
        return builder.create();

    }
}

I want the dialog to have a transparent background. Currently, as shown in the picture, there is the WidgetConfigure activity as background.

Thankful for any help.

Marcus

Marcus
  • 6,697
  • 11
  • 46
  • 89
  • Sanghyun Byun answered this question very adequately here: http://stackoverflow.com/questions/8045556/cant-make-the-custom-dialogfragment-transparent-over-the-fragment Though it's probably better to put the line of code in the onCreateView – user2288580 Jul 29 '15 at 08:41

1 Answers1

0

Using below code we can get transparent AlertDialog

AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(),android.R.style.Theme_Translucent);

But in your case you have some choices to be displayed in alert dialog. In that case you need to create a layout with transparent background with choice list and set that layout to dialog.

something like this

View view = getActivity().getLayoutInflater().inflate(R.layout.dialog, null);
builder.setView(view);