8

I'm displaying an horizontal progress bar in my action bar. My problem is the progress bar width is not the action bar width, but smaller (but centered). Is that a normal behavior? How can I give it the screen width?

I'm using this in onCreate

 requestWindowFeature(Window.FEATURE_PROGRESS); 

and this in my methods

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

Thanks in advance.

2
  • Have you tried testing in the emulator and at least 2 different devices? Commented Jul 19, 2013 at 23:37
  • can you put a screen of that? Commented Jul 20, 2013 at 23:56

2 Answers 2

2

There is an attribute android:progressBarPadding in the action bar style. Set it to 0dip.

<style name="MyActionBar" parent="@android:style/Widget.Holo.ActionBar"> <item name="android:progressBarPadding">0dip</item> </style> 
Sign up to request clarification or add additional context in comments.

Comments

0

You need to delete 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 progress bar. In it width="match_parent". Uncomment actionBar.setCustomView and this method to inflate your actionBar with your own custom view.

Try that and give me a sing does it work for you.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.