在android中设置剩余进度条颜色

在android中设置剩余进度条颜色,android,android-layout,android-activity,android-progressbar,Android,Android Layout,Android Activity,Android Progressbar,我正在使用以下样式代码设置进度条的颜色 <item android:id="@android:id/progress"> <clip> <shape> <corners android:radius="0dip" /> <gradient android:angle="0" android:endColor="#36A19C"

我正在使用以下样式代码设置进度条的颜色

<item android:id="@android:id/progress">
    <clip>
      <shape>
        <corners android:radius="0dip" />
          <gradient
            android:angle="0"
            android:endColor="#36A19C"
            android:startColor="#36A19C" />
      </shape>
    </clip>
  </item>

我的进度条如下图所示



如何设置进度条中显示的灰色部分的颜色???

尝试查看一些教程和

在绘图窗口中创建一个文件
custom_progressbar.xml

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

<!-- Define the background properties like color etc -->
    <item android:id="@android:id/background">
        <shape>
            <gradient
                    android:startColor="backgroundColor"
                    android:endColor="backgroundColor"
                    android:angle="0"
            />
        </shape>
    </item>

 <!-- Define the progress properties like start color, end color etc -->
    <item android:id="@android:id/progress">
        <clip>
            <shape>
                <gradient
                    android:startColor="progressColor"
                    android:endColor="progressColor"
                    android:angle="0"
                />
            </shape>
        </clip>
    </item>

</layer-list>
您可以这样尝试:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

    <item android:id="@android:id/background">
        <shape>
            <solid android:color="@color/seekbar_background" />

            <stroke
                android:width="@dimen/seekbar_background_border"
                android:color="@android:color/transparent" />
        </shape>
    </item>
    <item android:id="@android:id/progress">
        <clip>
            <shape>
                <solid android:color="@color/seekbar_progress" />
            </shape>
        </clip>
    </item>

</layer-list>


进度条使用包含多个图层的图层列表。你需要背景进步。希望这对您有所帮助:)

将这行代码添加到进度条XML中

android:progressBackgroundTint="#ReplaceThisWithYourColor"

这对我很有用。

为什么progressbar的高度最终会这么大?如何使它变短?
android:progressBackgroundTint="#ReplaceThisWithYourColor"