0

Currently when I show a ProgressDialog, it takes up the whole screen including the tabs, like this:

enter image description here

Is it possible for this to only cover the activity and leave the tabs functional? Ideally it would appear like this so that I could click the buttons to leave load a different activity instead of waiting for the current one to finish loading:

enter image description here

Is this possible? Is there another approach I should take to achieve this result?

DaveDev
  • 41,155
  • 72
  • 223
  • 385

2 Answers2

0

Extend the progress dialog class where you do customisation

public class CustomProgressDialogClass extends ProgressDialog{

public CustomProgressDialogClass(Context context) {
    super(context, R.style.CustomDialogThemeForPorgressbar);
    // TODO Auto-generated constructor stub

}

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.progress_layout);
}

} In layout progress_layout

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" 
android:id="@+id/progressbar_layout">

<RelativeLayout
   android:id="@+id/relativeLayout1"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:gravity="center"
   android:background="@drawable/loader_bg"  >

   <ProgressBar
        android:id="@+id/progressbarlayout_progressbar"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"/>

In values folder create styles folder and paste this

<style name="CustomDialogThemeForPorgressbar" parent="@android:style/Theme.Dialog">
    <item name="android:windowBackground">@color/transparent</item>
    <item name="android:windowIsFloating">false</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:gravity">center</item>
</style>

Do the changes to windowIsFloating,gravity and windowNoTitle to show in tab host

vicky
  • 340
  • 5
  • 13
0

I feel that using the ProgressDialog is not the most suitable choice in a scenario like this. It is the logic of the dialog to block the entire window to indicate the user that no action can be performed at this moment.

If you want to show progress for certain parts of the activity, you should be using a ProgressBar instead. If you want the look and feel to be like a progress dialog, then use can customize the ProgressBar (that looks like the progress dialog), and dynamically attach/remove or change visibility to show or hide it.

I guess you can also take a look at this: https://stackoverflow.com/a/18553879/827110

(I am assuming you are looking for a conceptual answer i.e to find the most suitable way to achieve such a behaviour)

Community
  • 1
  • 1
Amulya Khare
  • 7,718
  • 2
  • 23
  • 38