Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用自定义ProgressDialog android_Android_Progressdialog - Fatal编程技术网

使用自定义ProgressDialog android

使用自定义ProgressDialog android,android,progressdialog,Android,Progressdialog,我在我的应用程序中使用自定义ProgressDialog,我可以自定义,但我还想删除ProgressDialog的上边框或窗口。 在styles.xml中,我将customDialog定义为 因此,请帮助我解决这个问题。任何帮助都应该非常感谢。只需在“进度构造函数”对话框中检查是否使用“活动名称” progressDialog = new ProgressDialog(Activity.this,R.style.CustomDialog); 我知道我很晚才回答,但我无论如何都会回答 Dia

我在我的应用程序中使用自定义
ProgressDialog
,我可以自定义,但我还想删除
ProgressDialog
的上边框或窗口。 在
styles.xml
中,我将
customDialog
定义为


因此,请帮助我解决这个问题。任何帮助都应该非常感谢。

只需在“进度构造函数”对话框中检查是否使用“活动名称”

 progressDialog = new ProgressDialog(Activity.this,R.style.CustomDialog);

我知道我很晚才回答,但我无论如何都会回答

Dialog dialog = new  Dialog(this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.dialog_login);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
将此添加到样式中

<item name="android:background">@android:color/transparent</item>

<item name="android:windowBackground">@android:color/transparent</item>
@android:color/transparent
@android:彩色/透明

将其添加到
样式.xml中的
自定义对话框中:

<item name="android:alertDialogStyle">@style/CustomAlertDialogStyle</item>

这个答案并没有解决问题中所述的问题,但在搜索如何实现自定义进度对话框时,这是指向该对话框的唯一链接。这就是说,我发现了一个由某个
Maksym Dybarskyi
编写的酷且易于使用的自定义进度对话框

所有功劳都归造物主,而不是我。我只是在分享

您只需将以下内容添加到依赖项:

dependencies {
...
   compile 'com.github.d-max:spots-dialog:0.4@aar'
}
然后是自定义样式:

<style name="Custom" parent="android:Theme.DeviceDefault.Dialog">
    <item name="DialogTitleAppearance">@android:style/TextAppearance.Medium</item>
    <item name="DialogTitleText">Please Wait</item>
    <item name="DialogSpotColor">@android:color/holo_orange_dark</item>
    <item name="DialogSpotCount">8</item>
</style>
结果:

黄点从左向右移动,您可以更改样式中的点数量


<style name="CustomDialog" parent="Theme.AppCompat.Light.Dialog">
   <item name="android:background">#7BC047</item>
   <item name="android:textColor">#FFFFFF</item>
   <item name="android:windowBackground">@color/colorTransparent</item>
</style>
#7BC047 #FFFFFF @彩色/彩色透明

这帮我完成了任务。

我正在应用程序中使用自定义
ProgressDialog
。 为此,我们必须遵循以下步骤

步骤1 创建一个xml布局
custom\u progress.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:padding="@dimen/dp_size_10"
    android:layout_height="match_parent">
<ProgressBar
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:indeterminateTint="@color/colorPrimary"
    android:layout_centerInParent="true"/>
</RelativeLayout>
步骤3 在activity java类中创建此自定义类的对象并初始化 如下所示,将对象用于
show()
disclose()

CustomProgressDialogue对象=新建CustomProgressDialogue(此)

并使用显示此对话框

object.show(); 并使用 object.discouse()

输出结果。

对于上述问题,这可能不是一个合适的答案。但这很有趣,我想在这里补充一下

(我不能以我目前的声誉发表评论)

检查这个

原作者添加了一个gif而不是默认的加载对话框,我认为
如果有改进,那么它将是一个很好的替代品。

看看。你的答案似乎微不足道。请详细说明您的建议。是否有任何方法可以使用此库更改警报对话框的背景?是的@GuruprasadRao在下面检查Khawar的答案
@color/transparent
添加这是样式不要忘记将以下内容添加到Proguard,否则点将不会出现在签名的APK
-keep class dmax.dialog.*{*}
请添加链接到您的答案的内容我已经添加了它。难道别人看不见吗谢谢@Deepak gupta这正是我想要的解决方案。它还有助于管理警报对话框的高度和宽度。谢谢
<style name="Custom" parent="android:Theme.DeviceDefault.Dialog">
    <item name="DialogTitleAppearance">@android:style/TextAppearance.Medium</item>
    <item name="DialogTitleText">Please Wait</item>
    <item name="DialogSpotColor">@android:color/holo_orange_dark</item>
    <item name="DialogSpotCount">8</item>
</style>
private AlertDialog progressDialog;
progressDialog = new SpotsDialog(mContext, R.style.Custom);

//Am using it in an AsyncTask. So in  my onPreExecute, I do this:
public void onPreExecute() {
  super.onPreExecute();
  progressDialog.show();
  ...
 }

//dismiss in onPostExecute
public void onPostExecute(){
   progressDialog.dismiss();
 } 
<style name="CustomDialog" parent="Theme.AppCompat.Light.Dialog">
   <item name="android:background">#7BC047</item>
   <item name="android:textColor">#FFFFFF</item>
   <item name="android:windowBackground">@color/colorTransparent</item>
</style>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:padding="@dimen/dp_size_10"
    android:layout_height="match_parent">
<ProgressBar
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:indeterminateTint="@color/colorPrimary"
    android:layout_centerInParent="true"/>
</RelativeLayout>
package com.example.customeprogress;
import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;

public class CustomProgressDialogue extends Dialog {
    public CustomProgressDialogue(Context context) {
        super(context);

        WindowManager.LayoutParams wlmp = getWindow().getAttributes();

        wlmp.gravity = Gravity.CENTER_HORIZONTAL;
        getWindow().setAttributes(wlmp);
        setTitle(null);
        setCancelable(false);
        setOnCancelListener(null);
        View view = LayoutInflater.from(context).inflate(
                R.layout.custom_progress, null);
        setContentView(view);
    }
}