Android - set a ProgressBar to be a vertical bar instead of horizontal?

后端 未结 14 685
不知归路
不知归路 2020-11-30 22:22

I am trying to use a ProgressBar as a metering like display. I thought it was going to be an easy task and thought that ProgressBar had a property to set to be vertical, bu

14条回答
  •  天命终不由人
    2020-11-30 23:11

    To utilize the ProgressBar and make it vertical, you would have to create your own custom View extending the ProgressBar view and override the onDraw() method. This will allow you to draw it in a reverse orientation. Take a look at the source code of the ProgressBar.onDraw() (located at the bottom of the link) for help on how to do this. Best case scenario, you'll just have to swap a few x and y variables.

提交回复
热议问题