Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Yes, create an Activity with style <code>Theme.Dialog</code>. This is a normal activity which looks like a dialog, while being modeless and accepting events.</p> <p>An example:</p> <pre><code>&lt;activity android:name=".activity.dialog.PhotoDialog" android:label="@string/photo_dialog_title" android:theme="@android:style/Theme.Dialog"/&gt; </code></pre> <p><strong>Edited</strong>: </p> <p>Indeed <code>Theme.Dialog</code> blurs the underlying activity and makes it unaccessible. I had a similar requirement here I had to show upload progress dialog with text and cancel button. The main catch is in setting <code>WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL</code> and resetting <code>WindowManager.LayoutParams.FLAG_DIM_BEHIND</code>.</p> <p>Created a Dialog with custom content:</p> <pre><code> if (progressDialog == null) { progressDialog = new Dialog(activityRequestingProgressDialog); progressDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); progressDialog.setContentView(R.layout.progress_upload); progressBar = (ProgressBar) progressDialog.findViewById(R.id.progressBar); progressText = (TextView) progressDialog.findViewById(R.id.progressText); progressText.setText("0 %"); progressText.setTextSize(18); Button buttonCancel = (Button) progressDialog.findViewById(R.id.btnCancel); buttonCancel.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { cancelProgressDialog(); stopUpload("Upload cancelled."); } }); Window window = progressDialog.getWindow(); window.setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL, WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL); window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); window.setGravity(Gravity.BOTTOM); progressDialog.show(); } progressText.setText(text); progressBar.setProgress(percent); </code></pre> <p>And this is the layout for this Dialog:</p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/progressDialog" android:orientation="vertical" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_centerVertical="true"&gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:textSize="18sp" android:padding="10dp" android:text="@string/progress_title"/&gt; &lt;LinearLayout android:id="@+id/progressDialog" android:orientation="horizontal" android:layout_height="wrap_content" android:layout_width="wrap_content" android:padding="10dp" android:layout_centerVertical="true"&gt; &lt;ProgressBar android:id="@+id/progressBar" android:layout_width="150dp" android:layout_height="34dp" android:paddingRight="10dp" android:max="100" android:progress="0" android:fadingEdge="vertical" style="?android:attr/progressBarStyleHorizontal"/&gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:id="@+id/progressText" android:paddingRight="10dp"/&gt; &lt;Button android:layout_height="40dp" android:layout_width="80dp" android:id="@+id/btnCancel" android:text="@string/dialog_cancel"/&gt; &lt;/LinearLayout&gt; &lt;/LinearLayout&gt; </code></pre>
 

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