4

Is it possible to increase the height of the line inside the progress bar ? enter image description here

Hadi Al Tinawi
  • 429
  • 7
  • 22

5 Answers5

4

I fixed it like this:

I created a custom progress bar xml file inside drawable folder:

progress_bar_states.xml:

    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">

  <item android:id="@android:id/background">
    <shape>
      <corners android:radius="5dip" />
      <gradient
        android:startColor="@color/colorGray"
        android:centerColor="@color/colorGray"
        android:endColor="@color/colorGray"
      />
    </shape>
  </item>



  <item android:id="@android:id/progress">
    <clip>
      <shape>
        <corners android:radius="5dip" />
        <gradient
          android:startColor="@color/colorBlue"
          android:centerColor="@color/colorBlue"
          android:endColor="@color/colorBlue"
        />     
      </shape>
    </clip>
  </item>



</layer-list>

And in my layout:

              <ProgressBar
                style="?android:attr/progressBarStyleHorizontal"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:indeterminateOnly="false"
                android:id="@+id/progressBar"
                android:gravity="left"
                android:progressDrawable="@drawable/progress_bar_states"
                android:layout_weight="1"
                android:layout_marginBottom="10dp"
                android:layout_marginLeft="15dp" />
Hadi Al Tinawi
  • 429
  • 7
  • 22
2

Try the following code:

mProgressBar.setScaleY(3f);
Yogi Bear
  • 603
  • 8
  • 22
1

In activity_main.xml

in ProgressBar section

change

style="?android:attr/progressBarStyleHorizontal"

to

style="@android:style/Widget.ProgressBar.Horizontal"
eyllanesc
  • 235,170
  • 19
  • 170
  • 241
1

Just with android:scaleY="4f" ! you can Increase this to 7f and the height be larger !

 <androidx.appcompat.widget.AppCompatSeekBar
            android:id="@+id/seekbar_deadline"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:maxHeight="@dimen/margin_20"
            android:minHeight="8dp"
            android:scaleY="4f"
            app:layout_constraintTop_toBottomOf="@+id/constraint_reason"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            android:layout_marginTop="@dimen/margin_24"
            android:layout_marginEnd="@dimen/margin_16"
            android:progressTint="@color/green_blue"
            android:progress="30"
            android:layoutDirection="rtl"
            app:layout_constraintCircleRadius="@dimen/padding_8"
            android:backgroundTint="@color/card_dialog_background"
            android:thumbTint="@color/transparent"
            android:layout_marginStart="@dimen/margin_16"
            />

enter image description here

Sana Ebadi
  • 6,656
  • 2
  • 44
  • 44
0

Set the layout of progress bas programtically. Use code like below.

        ProgressBar progressBar = new ProgressBar(teste.this, null, android.R.attr.progressBarStyleHorizontal);

        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(300, 10);

        progressBar.setLayoutParams(params );
        LinearLayout linearLayout = new LinearLayout(getApplicationContext());
        linearLayout.addView(progressBar);
        setContentView(linearLayout);
Bholu Bhaiya
  • 167
  • 1
  • 1
  • 12