With the new Toolbar API in Android Lollipop and AppCompat-v7, they are removing a lot of the automatic features to make Toolbar/ActionBar more robust. One of those things is the progress bar. Since Toolbar is simply a ViewGroup, I assumed adding a ProgressBar would be simple. However, I cannot seem to get it to work properly.
I have done the following (using the SmoothProgressBar library):
// I instantiate the toolbar and set it as the actionbar
mToolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(mToolbar);
// I create a ProgressBar and set the drawable to the SmoothProgressBar drawable
ProgressBar progressBar = new ProgressBar(this);
progressBar.setIndeterminateDrawable(new SmoothProgressDrawable.Builder(this).color(Color.BLUE).interpolator
(new DecelerateInterpolator()).sectionsCount(4).separatorLength(8).speed(2f).mirrorMode(true).build());
// I add the progressbar to the view with what I thought were the proper LayoutParams.
Toolbar.LayoutParams params = new Toolbar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 20);
params.gravity = Gravity.BOTTOM;
mToolbar.addView(progressBar, params);
progressBar.setIndeterminate(true);
I had figured this would work as I'm simply adding a ProgressBar to the bottom of the ViewGroup. However, it is not showing at all and is removing the Title. Below you can see a before and after. Does anyone know how to go about fixing this? My goal is to have a ProgressBar underneath the actionbar.
Before
After