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;
}
}