Reputation: 1459
I want to show the progress bar in my action bar. I tried to show it, but when I am trying to do it, I am getting both progress bar, spinner and horizontal in action bar.
At top blue horizontal progress bar is running and on right spinner is running. But I want only top blue progress bar below the Hubsystem logo. I don't know why spinner bar is showing.
I am using following code :
RequestWindowFeature(Android.Views.WindowFeatures.Progress);
base.OnCreate(bundle);
SetProgressBarIndeterminateVisibility(true);
SetProgressBarIndeterminate(true);
SetProgressBarVisibility(true);
How I can get only blue progress bar at bottom of action bar?
Upvotes: 0
Views: 1505
Reputation: 3632
It's simple to design just add a progress bar with horizontal style to your activity's main layout.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical"
android:layout_width="match_parent" android:layout_height="match_parent">
<ProgressBar android:id="@+id/activity_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="-8dp"
style="@android:style/Widget.DeviceDefault.ProgressBar.Horizontal"
/>
<!-- Other layouts -->
</LinearLayout>
Here I kept android:layout_marginTop="-8dp" because if you have the shadow to your action bar then it will adjust near to action bar. If there is no shadow then adjust according to you.
Note: This is acceptable only if you are using ToolBar in your XML layout. If you are doing with custom coding then do like this in your MainActivity.
public abstract class MainActivity extends Activity {
private ProgressBar mProgressBar;
@Override
public void setContentView(View view) {
init().addView(view);
}
@Override
public void setContentView(int layoutResID) {
getLayoutInflater().inflate(layoutResID,init(),true);
}
@Override
public void setContentView(View view, ViewGroup.LayoutParams params) {
init().addView(view,params);
}
private ViewGroup init(){
super.setContentView(R.layout.progress);
mProgressBar = (ProgressBar) findViewById(R.id.activity_bar);
return (ViewGroup) findViewById(R.id.activity_frame);
}
protected ProgressBar getProgressBar(){
return mProgressBar;
}
}
Upvotes: 1