Drawable - custom_progressbar.xml
<?xml version="1.0" encoding="utf-8"?><rotate xmlns:android="http://schemas.android.com/apk/res/android" android:fromDegrees="0" android:pivotX="50%" android:pivotY="50%" android:toDegrees="1440">
<shape android:innerRadiusRatio="3" android:shape="ring" android:thicknessRatio="8" android:thickness="4dp" android:useLevel="false">
<gradient android:angle="0" android:endColor="@color/brand_color" android:startColor="@android:color/transparent" android:type="sweep" android:useLevel="false" />
</shape>
</rotate>
<LinearLayout android:id="@+id/llProfile" android:layout_width="match_parent" android:layout_height="wrap_content" android:clickable="true" android:gravity="center_horizontal" android:orientation="horizontal" android:padding="@dimen/base_padding">
<RelativeLayout android:layout_width="180dp" android:layout_height="180dp">
<de.hdodenhof.circleimageview.CircleImageView android:id="@+id/ivProfile" android:layout_width="120dp" android:layout_height="120dp" android:layout_centerInParent="true" android:src="@mipmap/motherboard" app:civ_border_color="@color/grey_300" app:civ_border_width="1dp" />
<ImageView android:layout_width="32dp" android:layout_height="32dp" android:layout_below="@+id/ivProfile" android:layout_gravity="bottom" android:layout_marginLeft="-20dp" android:layout_marginTop="-15dp" android:layout_toRightOf="@+id/ivProfile" android:tint="@color/black" app:srcCompat="@drawable/ic_edit_profile" />
<ProgressBar android:id="@+id/progress_bar" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_centerInParent="true" android:indeterminateDrawable="@drawable/custom_progress_dialog" android:visibility="gone" />
</RelativeLayout>
</LinearLayout>
private void initProgressBar() {
progressBar = new ProgressBar(this, null, android.R.attr.progressBarStyleLarge);
progressBar.setIndeterminate(true);
RelativeLayout relativeLayout = new RelativeLayout(this);
relativeLayout.setGravity(Gravity.CENTER);
relativeLayout.setBackgroundColor(Color.TRANSPARENT);
relativeLayout.addView(progressBar);
RelativeLayout.LayoutParams params = new
RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
// progressBar.setVisibility(View.INVISIBLE);
this.addContentView(relativeLayout, params);
progressBar.setVisibility(View.VISIBLE);
}