Android: Start the circular progress bar from top (270°) -


i have defined circular progress bar using following drawable "ciruclar_progress_bar.xml"

<?xml version="1.0" encoding="utf-8"?> 

<item android:id="@android:id/progress">     <shape         android:innerradiusratio="2.5"         android:shape="ring"         android:thicknessratio="25.0" >         <gradient             android:centercolor="@color/gray"             android:endcolor="@color/gray"             android:startcolor="@color/gray"             android:type="sweep" />     </shape> </item> <item android:id="@android:id/secondaryprogress">     <shape         android:innerradiusratio="2.5"         android:shape="ring"         android:thicknessratio="25.0" >         <gradient             android:centercolor="@color/green"             android:endcolor="@color/green"             android:startcolor="@color/green"             android:type="sweep" />     </shape> </item> 

and have used drawable progressbar in layout using following code

  <progressbar             android:id="@+id/progresswheel"             style="?android:attr/progressbarstylehorizontal"             android:layout_width="152dp"             android:layout_height="152dp"             android:layout_centerinparent="true"             android:progress="100"             android:indeterminate="false"             android:progressdrawable="@drawable/circular_progress_bar" /> 

i show progress on progressbar following code progresswheel.setsecondaryprogress(percent); (used secondary progress because green color should come on top of black color of ring.)

this draws circular progressbar starting position on right (0°) shown in following image

enter image description here

i want progress start top shown in following image

enter image description here

i tried putting android:angle="270" in gradient tag of drawable xml had no luck. there way can start sweep angle top?

try specifying rotation degrees progress items.

<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" >     <item android:id="@android:id/progress">         <rotate             android:fromdegrees="270"             android:todegrees="270"             android:pivotx="50%"             android:pivoty="50%" >             <shape                 android:innerradiusratio="2.5"                 android:shape="ring"                 android:thicknessratio="25.0" >                 <gradient                     android:centercolor="@color/gray"                     android:endcolor="@color/gray"                     android:startcolor="@color/gray"                     android:type="sweep" />             </shape>         </rotate>     </item>     <item android:id="@android:id/secondaryprogress">         <rotate             android:fromdegrees="270"             android:todegrees="270"             android:pivotx="50%"             android:pivoty="50%" >             <shape                 android:innerradiusratio="2.5"                 android:shape="ring"                 android:thicknessratio="25.0" >                 <gradient                     android:centercolor="@color/green"                     android:endcolor="@color/green"                     android:startcolor="@color/green"                     android:type="sweep" />             </shape>         </rotate>     </item> </layer-list>     

Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -