Right to Left ProgressBar?

前端 未结 8 1912
陌清茗
陌清茗 2020-12-05 23:50

Does anyone know how to make a View reversed, I have a horizontal ProgressBar and I want it to right to left instead of left to right

8条回答
  •  情书的邮戳
    2020-12-06 00:17

    You don't need to rotate the entire View.

    Just use a single xml attribute in your my_progress_drawable.xml:

    
    
        
        
             
        
    
    
    

    The documentation tells us that gravity="right" does this:

    Put the object at the right edge of its container, not changing its size. When clipOrientation is "horizontal", clipping occurs at the left side of the drawable.

    Don't override onDraw(). This implementation is more stable across different versions of Android.

    Unfortunately, it's impossible to set the gravity of a ClipDrawable programmatically without invoking its constructor.

提交回复
热议问题