首页 > 解决方案 > Android ProgressBar size take whole screen

问题描述

I'm trying to implement an Android ProgressBar but its size is taking the whole screen. I've followed a couple of examples but it didn't make any effect.

Here is my code

<ProgressBar
        android:id="@+id/progress"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:indeterminate="false"
        android:padding="45dp"
        android:visibility="gone" />

标签: androidandroid-progressbar

解决方案


ProgressBar占用整个屏幕大小,可能是因为您已将layout-widthand/or设置layout-heightmatch-parent.

所以试着改变那些。

或者,如果您在 a上将layout-widthand设置layout-height0dpConstraintLayout,那么请确保您没有将Constraints设置为parent所有/相对侧。

如果您使用的是LinearLayout,并且您已将layout-width或设置layout-height0dp,请确保您没有将 设置为与布局的其他小部件layout-weight的尺寸相差太大的尺寸。layout-weight

希望这有帮助。下次,请发布您的代码甚至截图。这让我们所有人都轻松多了。


推荐阅读