I am trying to get border around a progress bar, but not able to get
What I am getting:
I don't want to fill the background with blue colour.
This is what I 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>
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:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With