MarkMa
MarkMa

Reputation: 57

Progress doesn't displayed on ProgressBar

Progress according to android:progress="60" doesnt displayed

enter image description here

Progressbar in activity_main.xml

<ProgressBar
    android:id="@+id/circle"
    style="?android:progressBarStyleHorizontal"
    android:layout_width="172dp"
    android:layout_height="3dp"
    android:layout_marginStart="8dp"
    android:layout_marginEnd="8dp"
    android:layout_marginBottom="8dp"
    android:progress="60"
    android:progressDrawable="@drawable/circle"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.497"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="@+id/gButton"
    app:layout_constraintVertical_bias="0.323"
    tools:layout_constrainedWidth="true" />

id and progressdrawable have a circle value, since At first I tried to make a round progress bar, but there was the same situation (despite android:progress="60" it appears as if the progressbar is 100)

shape.xml:

<?xml version="1.0" encoding="utf-8"?>

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle"
    android:useLevel="false"
    >

    <gradient android:useLevel="false"
        android:endColor="#6be400"
        android:centerColor="#008500"
        android:startColor="#6be400"/>

Upvotes: 0

Views: 238

Answers (2)

SnakeException
SnakeException

Reputation: 1186

Here is an easy fix: use android:background and not android:progressDrawable.

Add this and remove your attributes android:progressDrawable and style:

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

android:background="@drawable/shape"
android:progressTint="someColor"
android:progressBackgroundTint="#0000"

Preview:

enter image description here

Upvotes: 3

SABANTO
SABANTO

Reputation: 1506

Try adding

android:indeterminate="false"
android:max="100"

Progress is calculated as a fraction of the max value and you are trying to create a determinate progressBar

Upvotes: 0

Related Questions