问题
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" />
回答1:
The ProgressBar is taking the whole screen size, probably because you've set the layout-width
and/or layout-height
to match-parent
.
So try changing those.
Or, if you set the layout-width
and layout-height
to 0dp on a ConstraintLayout
, then make sure you're not setting the Constraints to parent
on all / opposite sides.
If you're using a LinearLayout
, and if you've set either the layout-width
or layout-height
to 0dp, then make sure you aren't setting the layout-weight
to a size that's too different from the layout-weight
of the other widgets of the layout.
Hope this helped. Next time, please post your code or even a screenshot. That makes it a lot easier for all of us.
来源:https://stackoverflow.com/questions/51128644/android-progressbar-size-take-whole-screen