Android Shape屬性創(chuàng)建環(huán)形進(jìn)度條
1,實(shí)現(xiàn)效果
2,實(shí)現(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è)置給一個(gè)旋轉(zhuǎn)動(dòng)畫(huà),并利用該旋轉(zhuǎn)動(dòng)畫(huà)自定義成一個(gè)環(huán)形進(jì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)形進(jìn)度條,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
如果你覺(jué)得本文對(duì)你有幫助,歡迎轉(zhuǎn)載,煩請(qǐng)注明出處,謝謝!
相關(guān)文章
android TextView 設(shè)置和取消刪除線的兩種方法
這篇文章主要介紹了android TextView 設(shè)置和取消刪除線的兩種方法,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2018-03-03Android使用CardView實(shí)現(xiàn)圓角對(duì)話框
這篇文章主要為大家詳細(xì)介紹了Android使用CardView實(shí)現(xiàn)圓角對(duì)話框,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-11-11基于Viewpager2實(shí)現(xiàn)登錄注冊(cè)引導(dǎo)頁(yè)面
這篇文章主要為大家詳細(xì)介紹了基于Viewpager2實(shí)現(xiàn)登錄注冊(cè)引導(dǎo)頁(yè)面,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-09-09Android中TextView顯示圓圈背景或設(shè)置圓角的方法
TextView顯示文本給用戶,并允許他們選擇編輯。TextView是一個(gè)完整的文本編輯器,但是其基本類配置為不允許編輯。下面這篇文章主要給大家介紹了關(guān)于Android中TextView顯示圓圈背景或設(shè)置圓角的方法,需要的朋友可以參考借鑒,下面來(lái)一起看看吧。2017-05-05Android實(shí)現(xiàn)短信驗(yàn)證碼自動(dòng)填寫(xiě)
這篇文章主要為大家詳細(xì)介紹了Android短信驗(yàn)證碼自動(dòng)填寫(xiě)功能的實(shí)現(xiàn)過(guò)程,感興趣的小伙伴們可以參考一下2016-08-08Android實(shí)現(xiàn)簡(jiǎn)單的下拉刷新pulltorefresh
這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)簡(jiǎn)單的下拉刷新pulltorefresh的相關(guān)代碼,具有一定的實(shí)用性和操作價(jià)值,感興趣的小伙伴們可以參考一下2016-07-07使用RecyclerView實(shí)現(xiàn)水平列表
這篇文章主要為大家詳細(xì)介紹了使用RecyclerView實(shí)現(xiàn)水平列表,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-09-09