Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I did some testing and I feel that the best way to achieve this is doing a custom <code>Dialog</code>.</p> <p>Here is an example of what I did. This will answer question number 2 but will give you an idea of how to fix question number 1.</p> <pre><code>public class MyProgressDialog extends Dialog { public static MyProgressDialog show(Context context, CharSequence title, CharSequence message) { return show(context, title, message, false); } public static MyProgressDialog show(Context context, CharSequence title, CharSequence message, boolean indeterminate) { return show(context, title, message, indeterminate, false, null); } public static MyProgressDialog show(Context context, CharSequence title, CharSequence message, boolean indeterminate, boolean cancelable) { return show(context, title, message, indeterminate, cancelable, null); } public static MyProgressDialog show(Context context, CharSequence title, CharSequence message, boolean indeterminate, boolean cancelable, OnCancelListener cancelListener) { MyProgressDialog dialog = new MyProgressDialog(context); dialog.setTitle(title); dialog.setCancelable(cancelable); dialog.setOnCancelListener(cancelListener); /* The next line will add the ProgressBar to the dialog. */ dialog.addContentView(new ProgressBar(context), new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); dialog.show(); return dialog; } public MyProgressDialog(Context context) { super(context, R.style.NewDialog); } } </code></pre> <p>All the static methods comes from <a href="http://www.netmite.com/android/mydroid/frameworks/base/core/java/android/app/ProgressDialog.java" rel="noreferrer">this</a> link, nothing strange, but the magic occurs in the constructor. Check that I pass as parameter an style. That style is the following:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;resources&gt; &lt;style name="NewDialog" parent="@android:Theme.Dialog"&gt; &lt;item name="android:windowFrame"&gt;@null&lt;/item&gt; &lt;item name="android:windowBackground"&gt;@android:color/transparent&lt;/item&gt; &lt;item name="android:windowIsFloating"&gt;true&lt;/item&gt; &lt;item name="android:windowContentOverlay"&gt;@null&lt;/item&gt; &lt;item name="android:windowTitleStyle"&gt;@null&lt;/item&gt; &lt;item name="android:windowAnimationStyle"&gt;@android:style/Animation.Dialog&lt;/item&gt; &lt;item name="android:windowSoftInputMode"&gt;stateUnspecified|adjustPan&lt;/item&gt; &lt;item name="android:backgroundDimEnabled"&gt;false&lt;/item&gt; &lt;item name="android:background"&gt;@android:color/transparent&lt;/item&gt; &lt;/style&gt; &lt;/resources&gt; </code></pre> <p>The result of this is a <code>ProgressBar</code> rotating in the center of the screen. Without <code>backgroundDim</code> and without the <code>Dialog</code> box.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload