Android ProgressBar makes app to work slower

浪子不回头ぞ 提交于 2019-12-13 05:18:24

问题


I am making to show progressbar on postexecute and to be not visible in postExecute, and it works, but makes the app to work very slow, what is the reason is there any simple way to make it work normal(not slowly)? This is my code:

bar = (ProgressBar) this.findViewById(R.id.progressBar);     
getInfo extends AsyncTask<void, void, void>{   
    protected void onPreExecute() {   
        bar.setVisibility(View.VISIBLE);
    }   
    protected void doInBackground(String... params)                                                  
                  do smth}  
    protected void onPostExecute(Boolean results) {
              bar.setVisibility(View.GONE);
    }
}

回答1:


Are you using a custom progress bar and are you showing the progress bar at the initial screen of your application?

If you are using a custom progress bar then it might take some time to load during the initial startup of your app. I had a similar issue and the issue was due to the android:type="sweep" in the custom progress bar. EG: below

    <shape>
        <gradient
            android:startColor="#000001"
            android:centerColor="#ffffff"
            android:centerY="0.5"
            android:type="sweep"/>
    </shape>

Not sure why the type="sweep" could cause the issue but, after removing it, the application seemed to start up pretty quick



来源:https://stackoverflow.com/questions/21160361/android-progressbar-makes-app-to-work-slower

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!