progress bar - Android - Round ProgressBar starts at wrong place -
i'm trying add round progress bar app want start @ top of circle , end @ top. however, try angles etc doesn't change appearance. i'm new android go easy on me. here code:
<progressbar android:id="@+id/progressbar" android:layout_width="300dp" android:layout_height="300dp" android:indeterminate="false" android:layout_centerinparent="true" android:progressdrawable="@drawable/circular_progress_bar" android:background="@drawable/circle_shape" style="?android:attr/progressbarstylehorizontal" android:max="100" android:progress="30" />
circle_shape.xml
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="ring" android:innerradiusratio="2.5" android:thickness="6dp" android:uselevel="false"> <solid android:color="#ccc" /> </shape>
circular_progress_bar.xml
<?xml version="1.0" encoding="utf-8"?> <clip> <rotate xmlns:android="http://schemas.android.com/apk/res/android" android:fromdegrees="270" android:todegrees="270" > <shape android:innerradiusratio="2.5" android:shape="ring" android:thickness="6dp"> <gradient android:angle="0" android:endcolor="#38c0f4" android:startcolor="#38c0f4" android:centercolor="#56ccb7" android:type="sweep" android:uselevel="false" /> </shape> </rotate> </clip>
here screenshot of looks @ 30% progress:
you need edit circular_progress_bar.xml
- get rid of clip tags
add [android:uselevel="true"] shape properties. (this new android 5(21))
<rotate xmlns:android="http://schemas.android.com/apk/res/android" android:fromdegrees="270" android:todegrees="270" > <shape android:innerradiusratio="2.5" android:shape="ring" android:thickness="6dp" android:uselevel="true"> <gradient android:angle="0" android:endcolor="#38c0f4" android:startcolor="#38c0f4" android:centercolor="#56ccb7" android:type="sweep" android:uselevel="false" /> </shape> </rotate>
Comments
Post a Comment