Centering ProgressBar Programmatically in Android
I'm trying to center a ProgressBar programmatically using the following:
ViewGroup layout = (ViewGroup)
findViewById(android.R.id.content).getRootView();
progressBar =
newProgressBar(SignInActivity.this,null,android.R.attr.progressBarStyleLarge);
progressBar.setIndeterminate(true);
progressBar.setVisibility(View.VISIBLE);
RelativeLayout.LayoutParams params = new
RelativeLayout.LayoutParams(100,100);
params.addRule(RelativeLayout.CENTER_IN_PARENT);
layout.addView(progressBar,params);
The size setting seems to work okay, but the ProgressBar doesn't center in
the existing layout (defined by xml with a relative layout). Is there
something obviously wrong here?
Thanks.
No comments:
Post a Comment