Android中實(shí)現(xiàn)ProgressBar菊花旋轉(zhuǎn)進(jìn)度條的動畫效果
在一些常見到的加載中需要顯示一個加載動畫,如旋轉(zhuǎn)的菊花,旋轉(zhuǎn)的圈圈等等動畫…,然后我們現(xiàn)在就來說下怎么去試下它吧
一.菊花的旋轉(zhuǎn)動畫

1.新建一個drawable文件
在res/drawable下新建一個progressbar_style.xml文件定義一個旋轉(zhuǎn)動畫
<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/loading_01" //菊花圖片路徑
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="360">
</animated-rotate>
2.在布局ProgressBar控件中引入使用
<ProgressBar
android:background="@color/transparent"
android:indeterminateDuration="2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminateBehavior="repeat"
android:indeterminateDrawable="@drawable/progressbar_style"/>
二. 圓圈旋轉(zhuǎn)動畫

步驟跟上面是一樣的,使用也是一樣的,只是在progressbar_style.xml中定義的動畫效果是不一樣的
<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="360">
<shape
android:innerRadius="8dp"
android:thickness="3dp"
android:shape="ring"
android:useLevel="false">
<gradient
android:centerY="0.50"
android:endColor="#cccccc"
android:startColor="@color/white"
android:type="sweep"
android:useLevel="false" />
</shape>
<!-- android:pivotX 動畫執(zhí)行的起點(diǎn)x坐標(biāo) 50%代表相對自身寬度的
android:innerRadius 內(nèi)環(huán)的半徑
android:thickness 環(huán)的厚度
android:useLevel 只有當(dāng)我們的shape使用在LevelListDrawable中時,這個值為true,否則為false
android:centerY 漸變中心Y的相對位置,值為0-1
android:type 漸變類型,還有l(wèi)inear,radial兩種類型,線性漸變和放射漸變-->
</animated-rotate>
到此這篇關(guān)于Android中實(shí)現(xiàn)ProgressBar菊花旋轉(zhuǎn)進(jìn)度條的動畫效果的文章就介紹到這了,更多相關(guān)Android ProgressBar菊花旋轉(zhuǎn)內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Android 退出應(yīng)用程序的實(shí)現(xiàn)方法
這篇文章主要介紹了Android 退出應(yīng)用程序的實(shí)現(xiàn)方法的相關(guān)資料,需要的朋友可以參考下2017-04-04
Android 兩種方法實(shí)現(xiàn)長按返回健退出
這篇文章主要介紹了Android 兩種方法實(shí)現(xiàn)長按返回健退出的相關(guān)資料,需要的朋友可以參考下2017-02-02
Android入門之Style與Theme用法實(shí)例解析
這篇文章主要介紹了Android入門之Style與Theme用法,非常實(shí)用的功能,需要的朋友可以參考下2014-08-08
Android 自定義view之畫圖板實(shí)現(xiàn)方法
本文重在對自定義view,以及其常用類,常用方法的初步了解,提供一個思路,效果是其次,畫板只是例子,需要的朋友可以參考下2018-01-01
Android Studio導(dǎo)入項(xiàng)目非常慢的解決方法
這篇文章主要為大家詳細(xì)介紹了Android Studio導(dǎo)入項(xiàng)目非常慢的解決方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下2016-11-11
Android實(shí)現(xiàn)簡單旋轉(zhuǎn)動畫
這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)簡單旋轉(zhuǎn)動畫,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下2022-07-07

