Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Border around progress bar

I am trying to get border around a progress bar, but not able to get

What I am getting:

What I am getting

I don't want to fill the background with blue colour.

This is what I want:

Want

This is the XML file

<?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="#1669A0" />
        <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>
like image 893
Vishal Sanghani Avatar asked Jan 26 '16 09:01

Vishal Sanghani


1 Answers

Maybe it will be helpful for other people who have the same problem: You can just add line in shape section to add stroke (as a border) to it and then add proper padding in progress section (usually equal or bigger than stroke width).

Example:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:id="@android:id/background">
        <shape>
            <corners android:radius="10dp"/>
            <solid android:color="YOUR BACKGROUND COLOR HERE"/>
            <stroke android:color="YOUR BORDER COLOR HERE" android:width="5dp" />
        </shape>
    </item>

    <item android:id="@android:id/progress"
        android:top="5dp"
        android:bottom="5dp"
        android:right="5dp"
        android:left="5dp">
        <clip>
            <scale android:scaleWidth="100%" >
                <shape>
                    <corners android:radius="10dp"/>
                    <solid android:color="YOUR PROGRESS COLOR HERE"/>
                </shape>
            </scale>
        </clip>
    </item>
</layer-list>

You will get something like that: enter image description here

like image 176
Lotos Avatar answered Sep 30 '22 13:09

Lotos