Is it possible to increase the height of the line inside the progress bar ?
Asked
Active
Viewed 5,056 times
4

Hadi Al Tinawi
- 429
- 7
- 22
-
1follow this link : http://stackoverflow.com/questions/2819778/custom-drawable-for-progressbar-progressdialog – MrTy May 15 '17 at 10:59
-
@HùngNguyễn Thank you – Hadi Al Tinawi May 15 '17 at 12:51
5 Answers
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
-
I have tried this, it will scale the whole progress bar. I want to change the line height only. – Hadi Al Tinawi May 15 '17 at 12:38
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

Larry Seibel
- 11
- 1
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"
/>

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
-
-
LinearLayout.LayoutParams(300, 10); this line will set height and width of any widget, here progress bar with this line- progressBar.setLayoutParams(params ); – Bholu Bhaiya May 17 '17 at 05:59