我想在安卓中使用这种类型的进度条。我已经尝试了许多水平进度条,但它们看起来都像是默认进度条,只是颜色不同。不知道如何使用这种类型:
我想在安卓中使用这种类型的进度条。我已经尝试了许多水平进度条,但它们看起来都像是默认进度条,只是颜色不同。不知道如何使用这种类型:
<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);