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

后端 未结 14 701
不知归路
不知归路 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:15

    I know that it´s an old post but I found a very simple solution to this problem that maybe can help somebody. First at all create a progress_drawable_vertical.xml like this:

    
    
    
        
    
    
        
            
                
            
        
    
    
    

    Then just use this in your progressBar:

    
    

    I also have created an progress_drawable_horizontal.xml

    
    
    
        
    
    
        
            
                
            
        
    
    
    

    with the objetive of mantain the same style defined in progress_drawable_vertical.xml

    The key here is the correct use of android:clipOrientation and android:gravity.

    I found this solution here and the core of the solution is similar to jagsaund but a little bit more simple.

提交回复
热议问题