How to draw a line in the progress bar view?



I am trying to draw a vertical line in the progress bar.It has to be displayed at index 0 - 1 of the progress bar (maximum progress 100). I created a custom layer list for this purpose. I can manually adjust the x and y of the line. For example android:pivotX="6%" android:pivotY="6%". However, for each screen it looks differently. So for example, at current x and the line is displayed only in a landscape mode, however,it cannot be seen in the portrait mode at all. But if I increase x and y, I will also see the line in a portrait mode, but it will not work for a landscape mode. (see screenshots).


Custom design:



<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://ift.tt/nIICcg">

<item android:id="@android:id/background">
<shape>
<solid
android:color="@color/white_text_colour" />
</shape>
</item>

<item>

<rotate
android:fromDegrees="90"
android:toDegrees="90"
android:pivotX="6%"
android:pivotY="6%" >

<shape android:shape="line">
<solid android:color="@android:color/transparent" />
<stroke android:width="1dp" android:color="#ff0000" />
</shape>

</rotate>
</item>

<item
android:id="@android:id/progress">
<clip>
<shape>
<solid
android:color="@color/positive_progress_bar" />
</shape>
</clip>
</item>

</layer-list>


Portrait mode


Landscape mode


No comments:

Post a Comment