Android Shape屬性創(chuàng)建環(huán)形進度條
1,實現(xiàn)效果
2,實現(xiàn)代碼:
【1】 shape_drawable.xml 文件
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:innerRadius="20dp" android:shape="ring" android:thickness="8dp" android:useLevel="false" > <gradient android:angle="0" android:startColor="@color/normal" android:centerColor="#5027844F" android:endColor="#fff" android:useLevel="false" android:type="sweep" /> </shape>
【2】 我們將該自定義環(huán)形圈設(shè)置給一個旋轉(zhuǎn)動畫,并利用該旋轉(zhuǎn)動畫自定義成一個環(huán)形進度圈的style,最后將該自定義的style賦值給Progress組件。
progress_rotate文件
<?xml version="1.0" encoding="utf-8"?> <rotate xmlns:android="http://schemas.android.com/apk/res/android" android:drawable="@drawable/shape_drawable" android:pivotX="50%" android:pivotY="50%" android:fromDegrees="0" android:toDegrees="360" > </rotate>
【3】 自定義Progress的style:
CustomProgressStyle文件
<style name="CustomProgressStyle" > <item name="android:indeterminateDrawable">@drawable/progress_rotate</item> <item name="android:minWidth">72dp</item> <item name="android:maxWidth">72dp</item> <item name="android:minHeight">72dp</item> <item name="android:maxHeight">72dp</item> </style>
【4】 應(yīng)用到Progress組件
<ProgressBar android:layout_width="100dp" android:layout_height="100dp" android:layout_centerInParent="true" style="@style/CustomProgressStyle" android:indeterminateDuration="700" />
總結(jié)
以上所述是小編給大家介紹的Android Shape屬性創(chuàng)建環(huán)形進度條,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
如果你覺得本文對你有幫助,歡迎轉(zhuǎn)載,煩請注明出處,謝謝!
相關(guān)文章
android TextView 設(shè)置和取消刪除線的兩種方法
這篇文章主要介紹了android TextView 設(shè)置和取消刪除線的兩種方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-03-03Android使用CardView實現(xiàn)圓角對話框
這篇文章主要為大家詳細介紹了Android使用CardView實現(xiàn)圓角對話框,具有一定的參考價值,感興趣的小伙伴們可以參考一下2018-11-11基于Viewpager2實現(xiàn)登錄注冊引導(dǎo)頁面
這篇文章主要為大家詳細介紹了基于Viewpager2實現(xiàn)登錄注冊引導(dǎo)頁面,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下2022-09-09Android中TextView顯示圓圈背景或設(shè)置圓角的方法
TextView顯示文本給用戶,并允許他們選擇編輯。TextView是一個完整的文本編輯器,但是其基本類配置為不允許編輯。下面這篇文章主要給大家介紹了關(guān)于Android中TextView顯示圓圈背景或設(shè)置圓角的方法,需要的朋友可以參考借鑒,下面來一起看看吧。2017-05-05Android實現(xiàn)簡單的下拉刷新pulltorefresh
這篇文章主要為大家詳細介紹了Android實現(xiàn)簡單的下拉刷新pulltorefresh的相關(guān)代碼,具有一定的實用性和操作價值,感興趣的小伙伴們可以參考一下2016-07-07