gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 12:32:54 25 4
gpt4 key购买 nike

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

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

我的进度条如下图所示

enter image description here
如何设置进度条灰色部分的颜色???

最佳答案

尝试查看一些教程 herehere .

在您的 drawable 中创建一个文件 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>

在代码中将其设置为您的进度条

 // Get the Drawable custom_progressbar                     
Drawable customDrawable= res.getDrawable(R.drawable.custom_progressbar);
// set the drawable as progress drawavle
progressBar.setProgressDrawable(customDrawable);

关于android - 在android中设置剩余进度条颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28315976/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com