1

I have a grid of 9 surfaceViews in a layout. The user can click on any surfaceView to load a camera. During the loading process I need to show a ProgressDialog over that surface view. Currently I am doing it this way.

 pd = new ProgressDialog(getActivity(), R.style.MyTheme);
            pd.getWindow().setGravity(Gravity.CENTER_VERTICAL);
            pd.setCancelable(false);
            pd.setProgressStyle(android.R.style.Widget_Holo_ProgressBar_Large);
            pd.show();

This is obviously showing a progress dialog but it will be in the center of the screen.

How can I make it center over the surfaceView?

dmSherazi
  • 3,743
  • 5
  • 37
  • 62

1 Answers1

1

I think what you are looking for is a Progress bar not a Progress Dialog (Correct me if I'm wrong).

Difference between Progressbar and progressDialog

Edit:

This is the syntax for the progress bar.

ProgressBar(Context context, AttributeSet attrs, int defStyleAttr)

Here is an example to create a progress bar and center it.

// Initialize a new Progressbar
ProgressBar progressBar = new ProgressBar(this, null, android.R.attr.progressBarStyleSmall);
// Set the Gravity for the parent view group
linearLayout.setGravity(Gravity.CENTER);
// Add the Porgress bar to the parent view group
linearLayout.addView(progressBar);

Here Linear Layout is holding the progress bar. You can replace it with your parent view.

Community
  • 1
  • 1
Srikar Reddy
  • 3,650
  • 4
  • 36
  • 58