是否可以增加进度条内线的高度Android

Is it possible to increase the height of the line inside the progress bar Android

是否可以增加进度条内线的高度?

试试下面的代码:

mProgressBar.setScaleY(3f);

以编程方式设置进度条的布局。 使用如下代码。

        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);

我是这样修复的:

我在 drawable 文件夹中创建了一个自定义进度条 xml 文件:

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>

在我的布局中:

              <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" />

在activity_main.xml

在进度条部分

改变

style="?android:attr/progressBarStyleHorizontal"

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

只要android:scaleY="4f"!您可以将其增加到 7f 并且高度更大!

 <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"
            />