简体   繁体   中英

Create a gradient progress bar in android

I am trying to create a progress/indicator style bar for a small android application whereby i am able to define the progress of the bar and only that amount is visible/lit up. I would like it in a similar style to the below image but in the vertical direction. I have tried using progress bars and seek bars, however I cannot achieve the desired gradient. Any help on achieving a solution to the below image or for creating the gradient in the progress/seek bars would be very much appreciated!!

Progress Bar

you can use this , and modify based in your case

<?xml version="1.0" encoding="utf-8"?>
 <shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
    android:angle="90"
    android:startColor="#FF000000"
    android:gradientRadius="@dimen/activity_vertical_margin"
    android:endColor="@android:color/transparent"
    />
</shape>

and in the progress bar add this

        android:background="@drawable/drawable_gradient"

hope this help

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM