<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:context="net.pupli.lastlab.PupliProgressDialogFragment">
<android.support.constraint.Guideline
android:id="@+id/guideline12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.5" />
<me.zhanghai.android.materialprogressbar.MaterialProgressBar
android:id="@+id/progressbarMain"
style="@style/Widget.MaterialProgressBar.ProgressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminate="true"
app:layout_constraintEnd_toEndOf="@id/guideline12"
app:layout_constraintStart_toStartOf="@id/guideline12"
app:mpb_progressStyle="circular" />
</android.support.constraint.ConstraintLayout>
public class PupliProgressDialogFragment extends DialogFragment {
MaterialProgressBar progressbarMain;
public PupliProgressDialogFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_pupli_progress_dialog, container, false);
// make dialogFragment transparent
getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
// remove title of dialog fragment
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
// set dialogFragment non cancelable, so users can not dismiss progressbar from screen
this.setCancelable(false);
progressbarMain = view.findViewById(R.id.progressbarMain);
return view;
}
@Override
public void onResume() {
super.onResume();
// set width and hight of dialogFragment
getDialog().getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT);
}
}
Related