一、通過動畫實現
定義res/anim/loading.xml如下:
[html]
view plain
copy
print?
xml
version
="1.0"
encoding
="utf-8"
?>
<animation-list
android:oneshot
="false"
xmlns:android
="">
<item
android:duration
="150"
android:drawable
="@drawable/loading_01"
/>
<item
android:duration
="150"
android:drawable
="@drawable/loading_02"
/>
<item
android:duration
="150"
android:drawable
="@drawable/loading_03"
/>
<item
android:duration
="150"
android:drawable
="@drawable/loading_04"
/>
<item
android:duration
="150"
android:drawable
="@drawable/loading_05"
/>
<item
android:duration
="150"
android:drawable
="@drawable/loading_06"
/>
<item
android:duration
="150"
android:drawable
="@drawable/loading_07"
/>
animation-list>
二、通過自定義顏色實現
定義res/drawable/progress_small.xml如下:
[html]
view plain
copy
print?
xml
version
="1.0"
encoding
="utf-8"
?>
<rotate
xmlns:android
=""android:fromdegrees
="0"
android:pivotx
="50%"
android:pivoty
="50%"
android:todegrees
="360"
>
<shape
android:innerradiusratio
="3"
android:shape
="ring"
android:thicknessratio
="8"
android:uselevel
="false"
>
<gradient
android:centercolor
="#ffffff"
android:centery
="0.50"
android:endcolor
="#1e90ff"
android:startcolor
="#000000"
android:type
="sweep"
android:uselevel
="false"
/>
shape>
rotate>
三、使用一張進行自定義
定義res/drawable/progress_small.xml如下:
[html]
view plain
copy
print?
<rotate
xmlns:android
=""android:drawable
="@drawable/spinner_black_16"
android:pivotx
="50%"
android:pivoty
="50%"
android:fromdegrees
="0"
android:todegrees
="360"
/>
使用方法都一樣,
如下:
[html]
view plain
copy
print?
<progressbar
android:layout_width
="wrap_content"
android:layout_height
="wrap_content"
android:indeterminatedrawable
="@drawable/progress_small"
/>
也可以根據需要通過設定style來設定其大小! 一般只有使用預設的progrressbar的時候採用。對於上述三種自定義的方式,建議修改直接修改大小,或者shape;
[html]
view plain
copy
print?
<progressbar
android:layout_width
="wrap_content"
android:layout_height
="wrap_content"
android:layout_centerinparent
="true"
style
="?android:attr/progressbarstylesmall"
android:indeterminatedrawable
="@drawable/progress_small"
/>
設定成progressbarstylesmall後,圖示變小。
設定成progressbarstylelarge後,圖示變大
自定義刻度 Android自定義滑動刻度進度條
做到以上的效果圖,就可以知道,兩個模式,首先,定義相應的自定義屬性,額,沒辦法,上頭要求,所以規範點 新建乙個bar attrs.xml檔案 attr declare styleable resources 然後就是 中取得相應的屬性值和設定預設值 然後修改seekbar的線的顏色和滑動塊的屬性,通...
Android自定義環形進度條
主頁面 author 有點涼了 public class mainactivity extends activity catch interruptedexception e start override public boolean oncreateoptionsmenu menu menu ov...
android 自定義 環形進度條
其實這個控制項很簡單,繼承view,在ondraw 中 繪製乙個圓和乙個圓弧即可,如下,對外暴露了乙個設定進度的方法,難點主要是數學計算 public class circleview extends view private void initvalues private void init ov...