Remove vertical padding from horizontal ProgressBar

后端 未结 22 2016
眼角桃花
眼角桃花 2020-11-28 03:30

By default the ProgressBar has a certain padding above and below the bar itself. Is there a way to remove this padding so as to only have the bar in the end?

22条回答
  •  庸人自扰
    2020-11-28 04:21

    I ended up using a custom library to solve this issue. Most of the other solutions work but the results are not consistent across various devices.

    MaterialProgressBar

    • Consistent appearance on Android 4.0+.
    • Correct tinting across platforms.
    • Able to remove the intrinsic padding of framework ProgressBar.
    • Able to hide the track of framework horizontal ProgressBar.
    • Used as a drop-in replacement for framework ProgressBar.

    To add as a gradle dependency:

    compile 'me.zhanghai.android.materialprogressbar:library:1.1.7'
    

    To add a ProgressBar with no intrinsic padding to your layout:

    
    

    app:mpb_useIntrinsicPadding="false" does the trick. For more details see the GitHub page.

提交回复
热议问题