围绕定制进度对话框对话框、进度

2023-09-13 01:56:11 作者:我的身体里面有怪兽。

我创建了一个自定义ProgressDialog如下: 首先我有一个动画列表9连续Imges

I have created a Custom ProgressDialog as follows: First I have an Animation List with 9 sequential Imges

<?xml version="1.0" encoding="utf-8"?>

<item android:drawable="@drawable/icon_progress_dialog_drawable_1" android:duration="150" />
<item android:drawable="@drawable/icon_progress_dialog_drawable_2" android:duration="150" />
<item android:drawable="@drawable/icon_progress_dialog_drawable_3" android:duration="150" />
<item android:drawable="@drawable/icon_progress_dialog_drawable_4" android:duration="150" />
<item android:drawable="@drawable/icon_progress_dialog_drawable_5" android:duration="150" />
<item android:drawable="@drawable/icon_progress_dialog_drawable_6" android:duration="150" />
<item android:drawable="@drawable/icon_progress_dialog_drawable_7" android:duration="150" />
<item android:drawable="@drawable/icon_progress_dialog_drawable_8" android:duration="150" />
<item android:drawable="@drawable/icon_progress_dialog_drawable_9" android:duration="150" />

然后,我有一个自定义样式

Then I have a custom style

 <style name="CustomDialog" parent="@android:style/Theme.Dialog" >
    <item name="android:windowFrame">@null</item>
    <item name="android:windowBackground">@null</item>
    <item name="android:windowIsFloating">true</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowTitleStyle">@null</item>      
    <item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item>
    <item name="android:backgroundDimEnabled">false</item>
    <item name="android:gravity">center</item>
    <item name="android:minHeight">70dip</item>
    <item name="android:maxHeight">80dip</item>       

现在在code我把它叫做如下:

Now In code I call it as follows

 dialog = new ProgressDialog(KaguaHome.this); 
        dialog.setProgressStyle(R.style.CustomDialog);
        dialog.setIndeterminate(true);
        dialog.setIndeterminateDrawable(getResources().getDrawable(R.drawable.progress_dialog_icon_drawable_animation));
        dialog.show();

其结果是

The result is

然而,我想实现一个进步,只有图像对话框(无白色背景),并应居中,应该怎么修改?

I however want to achieve a progress Dialog with only the image (No white background) and It should be centered,what should I modify?

推荐答案

试试这个,说是如何工作的。我曾尝试这样做,对我来说它是在中央。

Try this and say how this works. I have tried this and for me it comes at center.

<style name="NewDialog" parent="@android:style/Theme.Dialog">
        <item name="android:windowFrame">@null</item>
        <item name="android:windowBackground">@android:color/transparent</item>
        <item name="android:windowIsFloating">true</item>
        <item name="android:windowContentOverlay">@null</item>
        <item name="android:windowTitleStyle">@null</item>
        <item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
        <item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item>
        <item name="android:backgroundDimEnabled">true</item>
        <item name="android:background">@android:color/transparent</item>
        <item ame="android:indeterminateDrawable">@anim/progress_dialog_icon_drawable_animation</item>
    </style>

和这个声明为

customDialog =新的对话框(getActivity(),R.style.NewDialog);

customDialog = new Dialog(getActivity(), R.style.NewDialog);

请参阅如果这个工程。