How do I set an Android ProgressBar's Size programmatically?

后端 未结 7 1640
盖世英雄少女心
盖世英雄少女心 2021-01-01 17:33

I have a custom view that extends ViewGroup. It includes a ProgressBar and a WebView. I\'m displaying the ProgressBar whi

7条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-01 17:52

    You can easily do via scaleX and scaleY property, here's how:

    progressBar.scaleX=0.5f
    progressBar.scaleY=0.5f
    

    Here,

    scaleX: To change the width, so 0.5 will reduce the width to the half of the actual width

    scaleY: To change the height, so 0.5 will reduce the height to the half of actual height

提交回复
热议问题