Right to Left ProgressBar?

前端 未结 8 1913
陌清茗
陌清茗 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:16

     public class inverseSeekBar extends ProgressBar {
    
    public inverseSeekBar(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        // TODO Auto-generated constructor stub
    }
    
    public inverseSeekBar(Context context, AttributeSet attrs) {
        super(context, attrs);
        // TODO Auto-generated constructor stub
    }
    
    public inverseSeekBar(Context context) {
        super(context);
        // TODO Auto-generated constructor stub
    }
    
    @Override
    protected synchronized void onDraw(Canvas canvas) {
        // TODO Auto-generated method stub
         canvas.save(); 
    
            //now we change the matrix
            //We need to rotate around the center of our text
            //Otherwise it rotates around the origin, and that's bad. 
            float py = this.getHeight()/2.0f;
            float px = this.getWidth()/2.0f;
            canvas.rotate(180, px, py); 
    
            //draw the text with the matrix applied. 
            super.onDraw(canvas); 
    
            //restore the old matrix. 
            canvas.restore(); 
    }}
       
    

    mypackage: com.test.testProgressBar

提交回复
热议问题