I am using custom ProgressDialog
in my application, I am able to make it custom but I also want to remove the upper border or window of progressDialog
.
In styles.xml
I define customDialog
as
<style name="AppTheme" parent="android:Theme.Light" />
<style name="CustomDialog" parent="@android:style/Theme.Dialog">
<item name="android:background">#7BC047</item>
<item name="android:textColor">#FFFFFF</item>
<item name="android:windowBackground">@null</item>
<item name="android:windowFrame">@null</item>
</style>
For removing the parent window I am setting windowBackground
to null and windowFrame
to null but it did't work for me.
Currently my custom progress dialog look like that in the image given below
I am using this code to set the style of progressDialog
.
private void showProgressDialog() {
progressDialog = new ProgressDialog(this,R.style.CustomDialog);
progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progressDialog.setMessage("Logging in. Please wait.");
progressDialog.show();
}
So,help me regarding this issue any help should be really appreciated.
java file to add progress code to display the progress dialog. Modify res/layout/activity_main. xml file to add respective XML code. Run the application and choose a running android device and install the application on it and verify the results.
This example demonstrates how to show a progress dialog in Android using Kotlin. Step 1 − Create a new project in Android Studio, go to File ⇉ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml.
This answer does not address the problem stated in the question, but when searching for how to implement a custom progress dialog, this is the only link pointing to SO. That said, I found a cool and easy-to -use custom progress dialog by a certain Maksym Dybarskyi
on this link.
All Credit goes to the creator, not me.Am just sharing
All you need to do is add this to your dependencies:
dependencies {
...
compile 'com.github.d-max:spots-dialog:0.4@aar'
}
And then the custom style:
<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>
Finally, in your code do this:
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();
}
Result:
The yellow dots move from left to right and you can change the number of dots in styles
I know I'm quite late to answer but I'll answer any way,
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));
I'm using custom ProgressDialog
in my application .
For that we have to follow some steps this are as follow.
step-1
Create a xml layout custom_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>
step-2 Create a java file for this custom dialog.
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);
}
}
step-3
Create a object of this custom class in your activity java class and initialised
it as follow use the object for show()
or dismiss()
CustomProgressDialogue object=new CustomProgressDialogue(this);
and show this dialog using.
object.show(); and dismissed it using object.dismiss();
Result of output. see out put here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With