我想在android中使用这种类型的进度条。我已经尝试了许多水平进度条。它们看起来都像具有不同颜色的默认进度条。不知道如何使用此类型:

发布于 2012-07-04 13:12:46
您将需要创建自己的自定义进度条。它不像使用许多水平条那么简单。
发布于 2013-06-03 20:17:09
自定义进度条需要定义进度条的背景和进度的属性。
在res-> drawable文件夹中创建名为customprogressbar.xml的a.xml文件
customprogressbar.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="#000001"
android:centerColor="#0b131e"
android:centerY="1.0"
android:endColor="#0d1522"
android:angle="270"
/>
</shape>
</item>
<!-- Define the progress properties like start color, end color etc -->
<item android:id="@android:id/progress">
<clip>
<shape>
<gradient
android:startColor="#007A00"
android:centerColor="#007A00"
android:centerY="1.0"
android:endColor="#06101d"
android:angle="270"
/>
</shape>
</clip>
</item>现在您需要设置以将progressDrawable属性设置为customprogressbar.xml(drawable)
您可以在xml文件或Activity(在运行时)中执行此操作
在您的xml中,请执行以下操作
<ProgressBar
android:id="@+id/progressBar1"
style="?android:attr/progressBarStyleHorizontal"
android:progressDrawable="@drawable/custom_progressbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />在运行时执行以下
// Get the Drawable custom_progressbar
Drawable draw= res.getDrawable(R.drawable.custom_progressbar);
// set the drawable as progress drawavle
progressBar.setProgressDrawable(draw);https://stackoverflow.com/questions/11322740
复制相似问题