How would I do a custom "loading" dialog during an AsyncTask like the one in the Bank of America app, for instance? See:
I basically don't want the popup ProgressDialog but instead one that is embedded into the layout.
It's not a ProgressDialog. It's just a ProgressBar. Put it on your layout and make it visible when it's necessary.
That's a ProgressBar view that can be added to any layout:
<ProgressBar
android:indeterminate="true"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
/>
Related
I'd like to put an indeterminate Progress Dialog material-compliant in my app. I found two ways to achieve it:
1- Using material-dialogs: https://github.com/afollestad/material-dialogs
2- Using the build-in dialogs of material-design-library: https://github.com/navasmdc/MaterialDesignLibrary#dialog
Using any of these solutions I get something pretty much like this: a dialog with a progressbar in it.
What I'd like to get is just the circular progress bar, without the surrounding light-grey view and without any text. A lot of apps proved us that the user knows that when something's spinning around he just needs to wait: there's no need to write it in letters. What I mean is pretty much something like this, but material.
I don't think this is such a strange question (or is it?) but I wasn't able to find any good answer online. Does anyone of you know how to achieve this?
Thank you
[Edit] I must say that in the gitHub issues of the material-dialogs library this seems to be discussed but the developer closes it fast by saying that it would mean not to follow the guidelines: https://github.com/afollestad/material-dialogs/issues/277
You can use this code,work fine in devices >= 19 (Kitkat)
progress = ProgressDialog.show(Splash.this, null, null, true);
progress.setContentView(R.layout.elemento_progress_splash);
progress.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
progress.show();
element progress splash.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#null"
>
<ProgressBar
android:id="#+id/progressBar1"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:backgroundTint="#color/ColorTipografiaAdeudos"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="10dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Comprobando sus datos"
android:layout_below="#+id/progressBar1"
android:layout_centerHorizontal="true"
android:id="#+id/textView6"
android:textSize="20dp"
android:textStyle="bold"
android:textColor="#color/ColorFuente"
android:layout_gravity="center_horizontal" />
</RelativeLayout>
To sum up our combined with the author efforts:
The main objective was to get a dialog appearance effect (specifically background dimming) for the progress indicator of a type "material progress wheel" with the transparent background of the dialog itself.
How we've gone about it (one of the possible ways):
This library is used as the material progress wheel.
A separate layout file is created (e.g., progress_wheel.xml) containing the progress wheel layout <com.pnikosis.materialishprogress.ProgressWheel>.... If you find yourself in a situation when the wheel's dimensions do not change as per your layout settings, wrap it with a FrameLayout with wrap_content dimensions.
Inflate this layout with a layout inflater to get a view, e.g. dialogView.
Create the dialog:
Dialog progressDialog = new Dialog(context);
progressDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
progressDialog.setContentView(dialogView);
progressDialog.show();
Call this function on dialogView to make the dialog background transparent:
public static void clearParentsBackgrounds(View view) {
while (view != null) {
final ViewParent parent = view.getParent();
if (parent instanceof View) {
view = (View) parent;
view.setBackgroundResource(android.graphics.Color.TRANSPARENT);
} else {
view = null;
}
}
}
I have a GridView which shows a grid of 15 Views for the first time. Then, on click of a button, I add 5 more grid views. So, my question is: How to add a ProgressBar at the bottom of a page, when those 5 Views are loading ? Like a spinner loading and the 5 Views get updated.
Hi i have a tab host tabwidget for tabs and gridview inside framlayout..now if i want the progressbar then should i need to inclue this linearlayout after frame layout or inside frame laoyout?
Add this below your GridView in the XML.
<LinearLayout
android:id="#+id/linlaProgressBar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal" >
<ProgressBar
style="#style/Spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="2dp" />
</LinearLayout>
And in your Activity, where you are loading the data (assuming, it is an AsyncTask), in your onPreExecute() show it:
#Override
protected void onPreExecute() {
// SHOW THE BOTTOM PROGRESS BAR (SPINNER) WHILE LOADING MORE PHOTOS
linlaProgressBar.setVisibility(View.VISIBLE);
}
And in the onPostExecute(), hide it:
#Override
protected void onPostExecute() {
// SHOW THE BOTTOM PROGRESS BAR (SPINNER) WHILE LOADING MORE PHOTOS
linlaProgressBar.setVisibility(View.GONE);
}
If you are not using an AsyncTask, then set the visibility to View.VISIBLE at the start of the method where you start downloading the data and set it to View.GONE either after or just before you set the Adapter.
EDIT: Adding additional info.
Couple of things.
You are downloading data off the Internet for which, I would recommend switching to AsycnTask instead of using a conventional () Method.
Check out my answer a few days ago on a similar question here: https://stackoverflow.com/a/13265776/450534
In that answer, you will find a complete solution that will suit your exact needs. Well, almost entirely anyway. You may have to make a few modifications and adapt to a few things yourself. But by and large, it will answer all your questions. I use it in my apps and they function as you say, the Google Play loading text at the bottom. And it really is complete. :-)
You need to create custom view for that and inflate it and add as bottom view in gridview
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<Button android:text="Load"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
/>
<ProgressBar
android:layout_width="25.0dip"
android:layout_height="25.0dip"
android:layout_centerInParent="true"
android:visibility="gone"
/>
</RelativeLayout>
now inflate this view and show the progressbar at bottom of gridview
You can set button as bottom with this when you click just visible the progressbar
Just add a ProgressBar in your layout, set its visibility to VISIBLE or GONE whenever you want to show/hide it.
Add a in the xml of GridView and set its property "alignParentRight = true" and "visibility = invisible" . In your activity , use Async task class and on its preExectue method set set its visibility to visible
pb.setVisibility(View.VISIBLE);
In doInBackground method load your images and finally in onPostExecute method make this progress bar invisible.
pb.setVisibility(View.INVISIBLE);
execute this async task class on click of load button.
This is an easy tutorial for understanding asyncTask
http://androidresearch.wordpress.com/2012/03/17/understanding-asynctask-once-and-forever/
Or threads can be used instead of async task.
I'd like to insert a progress spinner in AutoCompleteTextView while another class performs the autocomplete function.
I read about the frame Layout ed fixing it in the EditText but the question is:
How to set the progress spinner? And how to control it?
Use this in the layout where you want to display the ProgressBar. You can set the visibility, View.VISIBLE, View.GONE to make it visible and invisible.
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="#android:style/Widget.ProgressBar.Small"
android:layout_marginRight="5dp" />
I'm making a simple custom dialog for my android app, displaying only a seek bar. However, the complications of this simple task are driving me nuts.
My layout for the dialog is as follows:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp">
<SeekBar xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/dialogVolumeSlider"
android:layout_width="225dp"
android:layout_height="wrap_content"/>
</LinearLayout>
The dialog is created in code:
Dialog d = new Dialog(this);
d.setContentView(R.layout.custom_dialog);
return d;
Instead of a simple box wrapping the seekbar, I get this phantom space coming from somewhere:
What's the issue here? I've tried modifying
d.getWindow().getAttributes().height
but this creates additional problems as well.
Thanks for any help!!
EDIT: Stranger things happen when I assigned a fixed "50dp" to my LinearLayout's layout_height:
By default a Dialog will leave space for a title even if you don't set one (with d.setTitle()) .
You can either set a title to fill the space or request that the Dialog not have a title.
Here is an example of how to request the no title setting.
Dialog d = new Dialog(this);
d.requestWindowFeature(Window.FEATURE_NO_TITLE);
d.setContentView(R.layout.custom_dialog);
With no title, your SeekBar will appear as you expect.
Try putting a fixed Height on your parent linear layout. Something like:
android:layout_height="50px"
I'm using an AsyncTask to download Images for my Listview, because I dont want the download of the Images to block my UI-Thread. While the images are being loaded, I want to show an animated progress circle in the spot, where the image will be.
But I cant find an Image of the progress circle. What is the Ressource-Id? Or is there any other way? Does someone has a link to this image?
Look at the progress bar. It can work (and it does by default, AFAIR) in indeterminate mode, which means it shows a rotating circle, like the one you are asking for. I know this is not an image, but what you can do, is to place a FrameLayout instead of the image, with progress bar as the only child. Then, once the loading of the images finishes, remove the progress bar and add the image.
Define this a global variable ProgressDialog pd;
Just before launche the AsyncTask do:
pd = ProgressDialog.show(CurrentClassName.this,"This is the title","This is the detail text",true,false,null);
When its done onPostExecute just call pd.dismiss();
For more detail look at : ProgressDialog
You will have to take special considerations for it to work when you rotate the device while the dialog is up.
This is an example of a layout file for intro activity with an image and circle progress bar:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageView
android:id="#+id/imageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="#string/intro_description"
android:scaleType="fitXY"
android:src="#drawable/intro" />
<ProgressBar
android:id="#+id/progress"
style="?android:attr/progressBarStyleInverse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="150dp"
android:visibility="visible" />
</FrameLayout>
You want an indeterminate ProgressBar. Take a look at developer's website -
ProgressBar