最簡單的android自訂進度條樣式

來源:互聯網
上載者:User

標籤:

一、自訂圓形進度條樣式

1.在安卓項目drawable目錄下建立一個xml檔案如下:
<?xml version="1.0" encoding="utf-8"?><rotate xmlns:android="http://schemas.android.com/apk/res/android" android:pivotX="50%" android:pivotY="50%" android:fromDegrees="0" android:toDegrees="360" android:interpolator="@android:anim/accelerate_decelerate_interpolator" >
<--進度條圖片--> <bitmap android:antialias="true" android:filter="true" android:src="@drawable/loading360"/></rotate>

2.調用
<ProgressBar       android:layout_width="wrap_content"      android:layout_height="wrap_content"android:indeterminateDrawable="@drawable/progressbar1"/>


二 、自訂水平進度條

1.在安卓項目drawable目錄下建立一個xml檔案如下:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 背景 gradient是漸層,corners定義的是圓角 -->
<item android:id="@android:id/background">
<shape>
<corners android:radius="10dp" />

<solid android:color="#ffffff" />
</shape>
</item>
<!-- 第二條進度條顏色 -->
<item android:id="@android:id/secondaryProgress">
<clip>
<shape>
<corners android:radius="10dip" />

<gradient
android:angle="90.0"
android:centerColor="#ac6"
android:centerY="0.45"
android:endColor="#6c2"
android:startColor="#e71a" />
</shape>
</clip>
</item>
<!-- 進度條 -->
<item android:id="@android:id/progress">
<clip>
<shape>
<corners android:radius="10dip" />

<solid android:color="#F5e5" />
</shape>
</clip>
</item>

</layer-list>

2.調用
<ProgressBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:progress="20"
android:secondaryProgress="50"
style="@android:style/Widget.Holo.ProgressBar.Horizontal"
android:progressDrawable="@drawable/progress_color"
/>


最簡單的android自訂進度條樣式

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.