Custom Vertical Progress Bar
Asked Answered
D

0

7

I've made a custom vertical progress bar and I want to show labels along side it.

<?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="#777" />
        </shape>
    </item>
    <item android:id="@android:id/progress">
        <layer-list>
            <item>
                <clip
                    android:clipOrientation="vertical"
                    android:gravity="bottom">
                    <shape>
                        <gradient
                            android:angle="90"
                            android:centerColor="#FFFF00"
                            android:endColor="#FF0000"
                            android:startColor="#00FF00" />
                    </shape>
                </clip>
            </item>
            <item>
                <clip
                    android:clipOrientation="vertical"
                    android:gravity="fill">
                    <layer-list>
                        <item android:top="75dp">
                            <shape android:shape="line">
                                <stroke
                                    android:width="2dp"
                                    android:color="#333" />
                            </shape>
                        </item>

                        <item android:top="25dp">
                            <shape android:shape="line">
                                <stroke
                                    android:width="2dp"
                                    android:color="#333" />
                            </shape>
                        </item>

                        <item android:bottom="25dp">
                            <shape android:shape="line">
                                <stroke
                                    android:width="2dp"
                                    android:color="#333" />
                            </shape>
                        </item>

                        <item android:bottom="75dp">
                            <shape android:shape="line">
                                <stroke
                                    android:width="2dp"
                                    android:color="#333" />
                            </shape>
                        </item>
                    </layer-list>
                </clip>
            </item>
        </layer-list>
    </item>
</layer-list>

Usage:

<ProgressBar
    style="@android:style/Widget.ProgressBar.Horizontal"
    android:layout_width="10dp"
    android:layout_height="match_parent"
    android:layout_marginTop="@dimen/form_items_margin"
    android:layout_gravity="center"
    android:max="100"
    android:progress="90"
    android:progressDrawable="@drawable/progress_drawable_vertical" />

This is what mine looks like This is what mine looks like

This is What I wanted

This is what I wanted

Of course I couldn't achieve exactly like this But I only want to show labels alongside this now. I know I can make another vertical layout and show textview labels but that would be too messy. Is there any way I could adjust it in layer-list layout.

Diocletian answered 25/1, 2016 at 7:3 Comment(1)
have you implemented this? i also need to implement a design like your expected output.Tartaglia

© 2022 - 2024 — McMap. All rights reserved.