horizontal ProgressBar is not full parent width


horizontal ProgressBar is not full parent width



I am adding progress bar to my application AppBarLayout:


<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="?attr/appBarLayoutTheme">

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="?attr/toolbarPopupTheme"/>

<ProgressBar
style="?android:progressBarStyleHorizontal"
android:id="@+id/progress_loader"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="-8dp"
android:indeterminateTint="@color/greyishWhite"
android:layout_marginTop="-9dp"
android:maxWidth="2000dp"
android:indeterminateOnly="true"/>

</android.support.design.widget.AppBarLayout>



Everything looks ok in portrait mode:



enter image description here



But on landscape mode it doesn't take full parent width:



enter image description here



How can I force ProgressBar take full with at all times.



ANSWER:



Thanks @Mahavir Jain for guiding to the right path:



at the end all needed to do was change


android:indeterminateOnly="true"



to


android:indeterminate="true"





have you tried removing android:maxWidth="2000dp" from your `ProgressBar?
– Sagar
Jul 3 at 6:36


android:maxWidth="2000dp"





Yes, thats, why I added it in the first place, I thiught maybe progress bar has some kind of max width set by default, so I tried overrising it, but it didn't helped
– antanas_sepikas
Jul 3 at 6:38





Are you wrapping AppBarLayout in some other layout?
– Sagar
Jul 3 at 6:40


AppBarLayout





Yes, a CoordinatorLayout which is inside DrawerLayout
– antanas_sepikas
Jul 3 at 6:41





This is not issue of your progressbar view. Check parents of this view. Somewhere in tablet xml or dimens you are settings margins or padding
– Pankaj Kumar
Jul 3 at 6:43




2 Answers
2



Remove below line.



android:indeterminateOnly="true"



android:indeterminateOnly
Restricts to ONLY indeterminate mode (state-keeping progress mode will not work).


<ProgressBar
android:id="@+id/progress_loader"
style="?android:progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="-8dp"
android:layout_marginTop="-9dp"
android:indeterminateTint="@color/red"
android:max="100"
android:progress="100"
tools:ignore="UnusedAttribute" />



Set android:indeterminate="true" or try this style="@android:style/Widget.Holo.Light.ProgressBar.Horizontal" instead of


android:indeterminate="true"


style="@android:style/Widget.Holo.Light.ProgressBar.Horizontal"


style="?android:progressBarStyleHorizontal"






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

api-platform.com Unable to generate an IRI for the item of type

How to set up datasource with Spring for HikariCP?

PHP contact form sending but not receiving emails