先创建一个布局frag_setting_container,当作容器,里面带一个 圆形进度条, 异步加载结束的时候,向frag_setting_container 里面addView,在吧进度条隐藏掉,这样体验好一些
if (rootView == null)
rootView = inflater.inflate(R.layout.frag_setting_container,container,false);
progressLayLoading = rootView.findViewById(R.id.progressLayLoading);
AsyncLayoutInflater asyncLayInflater = new AsyncLayoutInflater(getActivity());
asyncLayInflater.inflate(R.layout.fragment_setting, container, new AsyncLayoutInflater.OnInflateFinishedListener() {
@Override
public void onInflateFinished(@NonNull View view, int resid, @Nullable ViewGroup parent) {
if (rootView instanceof ViewGroup){
((ViewGroup) rootView).addView(view);
}
if (progressLayLoading !=null)
progressLayLoading.setVisibility(View.GONE);
isViewLoaded = true;
if (isViewLoaded){
}
}
});
网友评论