更改dialogfragment背景颜色(使用Android Holo Colors Generator Xml模板)

Pil*_*ouk 0 android android-layout android-theme android-fragments

我的所有主题都在我的dialogfragment背景下工作.我试图让我的dialogFragment背景变黑,但我做错了什么.

这里到目前为止我在主题xml中得到了什么(请注意,我将它的顶部和底部封顶):

<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>
...
Run Code Online (Sandbox Code Playgroud)

这是我在我的对话框的Styles xml中得到的:

<style name="Dialogeasydealtheme" parent="android:Theme.Holo.Dialog">
<item name="android:textColor">#FFFFFF</item>
<item name="android:windowBackground">@color/test</item>
</style>
Run Code Online (Sandbox Code Playgroud)

以下是显示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");

    }
Run Code Online (Sandbox Code Playgroud)

这里的结果不起作用(白色应为黑色): DF

Guy*_*uyZ 7

在我遇到解决方案之前,我疯狂地找到了解决这个问题的方法.

    @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;
    }
Run Code Online (Sandbox Code Playgroud)