Question

All my theme is working beside my dialogfragment background. I try to make my dialogFragment background black but i'm doing something wrong.

Here what i got so far in the theme xml (Note that i trunked the top and the bottom of it):

<style name="easydealtheme" parent="@style/_easydealtheme"/>

  <style name="_easydealtheme" parent="android:Theme.Holo.Light.DarkActionBar">

<item name="android:editTextBackground">@drawable/easydealtheme_edit_text_holo_light</item>

<item name="android:dropDownListViewStyle">@style/Listviewdropdowneasydealtheme</item>
<item name="android:textViewStyle">@style/Textvieweasydealtheme</item>
<item name="android:editTextStyle">@style/Edittexteasydealtheme</item>

<item name="android:alertDialogTheme">@style/Dialogeasydealtheme</item>
...

Here is what i got in the Styles xml for my dialog :

<style name="Dialogeasydealtheme" parent="android:Theme.Holo.Dialog">
<item name="android:textColor">#FFFFFF</item>
<item name="android:windowBackground">@color/test</item>
</style>

Here is the code that show the dialogFragment :

 public static void ShowPhotoDialog(String title,File photoFile, FragmentManager fragM)
    {

        FragmentPhotoDialog photoD = new FragmentPhotoDialog();
        FragmentTransaction fTX  = fragM.BeginTransaction();
        photoD.SetStyle(DialogFragmentStyle.NoFrame, EasyDeal_Android.Resource.Style.easydealtheme);
        photoD.SetTile(title);
        photoD.SetPhotoFile(photoFile);
        photoD.Show(fTX, "Dialog");

    }

Here the result which is not working (The white should be black ) : DF

Was it helpful?

Solution

I went crazy finding a solution for this problem until I came across a solution.

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        // Setup the layout
        LayoutInflater inflater = getActivity().getLayoutInflater();
        final View root = inflater.inflate(*"YOUR LAYOUT"*, null);
        root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

        //Customizing the dialog features
        final Dialog dialog = new Dialog(getActivity());
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        dialog.setContentView(root);
        dialog.getWindow().setBackgroundDrawable(new ColorDrawable(getResources().getColor(*"YOUR SELECTED COLOR"*)));
        dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
        return dialog;
    }

OTHER TIPS

Try changing the alert dialog background as

<style name="Dialogeasydealtheme" parent="android:Theme.Holo.Dialog">
    <item name="android:textColor">#FFFFFF</item>
    <item name="android:background">@color/black</item>
</style>

Let me know if see any issue.

I find a solution not my favorite though but it will do.

I added a background to my layout. Here is the code on my main linearLayout:

<LinearLayout xmlns:p1="http://schemas.android.com/apk/res/android"
p1:orientation="vertical"
p1:minWidth="25px"
p1:minHeight="25px"
p1:layout_width="match_parent"
p1:layout_height="match_parent"
p1:id="@+id/liDialogPhoto"
p1:background="@drawable/easydealtheme_tilesbg">

I can now continue using no frame having a nice colored background !

Thanks for the help !

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top