Android ProgressBar

关于ProgressBar的颜色设置,基于不同的style,设置可以自定义样式及颜色等

例如:

style -> Widget.AppCompat.ProgressBar

通过查找属性定义-> indeterminateDrawable -> progress_static_material.xml 

在这个矢量的xml中可以找到其颜色配置是fillColor=“?attr/colorControlActivated”

如果只是修改颜色,最终只需要在Theme中

@color/colorAccent 即可修改颜色,不需要自定义.

另基于DialogFragment的全局性Loading

public class LoadingDialogFragmentextends DialogFragment {

public static LoadingDialogFragment newInstance() {

return new LoadingDialogFragment();

}

@Override

    public View onCreateView(LayoutInflater inflater, ViewGroup container,

Bundle savedInstanceState) {

getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);// 背景变暗.

        return super.onCreateView(inflater, container, savedInstanceState);

}

@Override

    public Dialog onCreateDialog(Bundle savedInstanceState) {

View v = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_loading_dialog,null);

AlertDialog dialog =new AlertDialog.Builder(getActivity())

.setView(v)

.create();

dialog.setCancelable(false);

dialog.setCanceledOnTouchOutside(false);

return dialog;

}

@Override

    public void onDestroyView() {

super.onDestroyView();

getActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);

}

}

较详细的Window参数配置:https://blog.csdn.net/angcyo/article/details/50613084

你可能感兴趣的:(Android ProgressBar)