Horizontal progress bar width in the action bar

I show a horizontal progress bar in the action bar. My problem is that the width of the progress bar is not the width of the action bar, but less (but centered). Is this normal behavior? How can I give it a screen width?

I use this in onCreate

requestWindowFeature(Window.FEATURE_PROGRESS); 

and this is in my methods

 public void setShowIndeterminateProgress(boolean val) { setProgressBarIndeterminate(true); setProgressBarVisibility(val); } 

Thanks in advance.

+8
android width android-actionbar progress
source share
2 answers

In the style of the action bar there is an android:progressBarPadding attribute android:progressBarPadding . Set it to 0dip .

 <style name="MyActionBar" parent="@android:style/Widget.Holo.ActionBar"> <item name="android:progressBarPadding">0dip</item> </style> 
+2
source share

You need to remove all items from your menu.

 @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); //inflater.inflate(R.menu.main, menu); ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(false); actionBar.setDisplayShowHomeEnabled(false); actionBar.setDisplayShowCustomEnabled(false); actionBar.setDisplayShowTitleEnabled(false); //actionBar.setIcon(R.drawable.ic_launcher); LayoutInflater inflator = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = inflator.inflate(R.layout.actionbar_main, null); //actionBar.setCustomView(view); return true; } 

Then after that create an xml layout with a progress bar. It has width = "match_parent". Uncomment the actionBar.setCustomView and this method to inflate your actionBar with your own custom view.

Try and let me sing, this will work for you.

0
source share

All Articles