Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android progress bar with padding

I want to make my progress bar looks something like that:

enter image description here

I dont want to use images, so I have tried to make this with the shapes:

<item android:id="@android:id/background">
    <shape>
        <corners android:radius="50dp" />

        <gradient
            android:angle="270"
            android:centerColor="#2a2723"
            android:centerY="0.75"
            android:endColor="#2a2723"
            android:startColor="#2a2723" />
    </shape>
</item>
<item android:id="@android:id/secondaryProgress">
    <clip>
        <shape>
            <corners android:radius="50dp" />

            <gradient
                android:angle="270"
                android:centerColor="#16e61c"
                android:centerY="0.75"
                android:endColor="#9dfd6e"
                android:startColor="#16e61c" />
        </shape>
    </clip>
</item>
<item android:id="@android:id/progress">
    <clip>
        <shape>
            <corners android:radius="50dp" />

            <gradient
                android:angle="270"
                android:endColor="#9dfd6e"
                android:startColor="#16e61c" />
        </shape>
    </clip>
</item>

But I cant set padding for the green line (Ive tried to set its everywhere where it was possible), and also I can't make such round corners (looks like corners android:radius isn't working). Please help me

like image 345
pleerock Avatar asked Jan 20 '12 10:01

pleerock


1 Answers

<?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="#222" />
            <corners android:radius="10dp" />
        </shape>
    </item>
    <item android:id="@android:id/progress">
        <clip>
            <layer-list>
                <item>
                    <color android:color="#00000000" />
                </item>
                <item
                    android:left="5dp"
                    android:top="5dp"
                    android:right="5dp"
                    android:bottom="5dp">
                    <shape>
                        <solid android:color="#00FF00" />
                        <corners android:radius="10dp" />
                    </shape>
                </item>
            </layer-list>
        </clip>
    </item>
</layer-list>

see my blog

like image 117
stedi Avatar answered Oct 26 '22 23:10

stedi