How to create 'Horizontal style' progress bar programmatically in Android?

血红的双手。 提交于 2020-01-01 23:12:55

问题


I am creating a ProgressBar in my app programmatically it is of SPIN style by default however I want it in HORIZONTAL style. I don't see any method/constant to achieve this.

And I don't want to use ProgressDialog as it'd be inconsistent with my App UI theme.

Any suggestions please?


回答1:


use this:

ProgressBar pb = new ProgressBar(context,
                                 null, 
                                 android.R.attr.progressBarStyleHorizontal);



回答2:


If you are using a ProgressDialog then, here is a way to change the style of the progressBar in the ProgressDialog.

mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);


来源:https://stackoverflow.com/questions/8727277/how-to-create-horizontal-style-progress-bar-programmatically-in-android

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