最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android?實(shí)現(xiàn)自定義圓形進(jìn)度條的三種常用方法

 更新時(shí)間:2023年03月01日 08:21:09   作者:jacklicto  
這篇文章主要介紹了Android?實(shí)現(xiàn)自定義圓形進(jìn)度條的三種常用方法的相關(guān)資料,需要的朋友可以參考下

Android 自定義 進(jìn)度條,一般有三種方式,最早一般使用UI給的圖片使用幀動(dòng)畫,完成,后面兩種,一種是使用自定義顏色,另外一種是使用帶相近色的圖片加動(dòng)畫完成。

下面具體 說(shuō)一下三種方式,推薦使用第二種方式,如果這種達(dá)不到效果,或者比較高也可使用第一種方式;

一、通過(guò)幀動(dòng)畫實(shí)現(xiàn)

1.首先在res 下新建設(shè) anim 文件夾,在里面新建XML 文件;

定義res/anim/loading.xml如下:

例:loading.xml

<?xml version="1.0" encoding="UTF-8"?>
<animation-list android:oneshot="false"
xmlns:android="http://schemas.android.com/apk/res/android">

<item android:duration="150" android:drawable="@drawable/pic1" />

<item android:duration="150" android:drawable="@drawable/pic2" />
<item android:duration="150" android:drawable="@drawable/pic3" />
<item android:duration="150" android:drawable="@drawable/pic4" />
<item android:duration="150" android:drawable="@drawable/pic5" />
<item android:duration="150" android:drawable="@drawable/pic6" />
<item android:duration="150" android:drawable="@drawable/pic7"

<item android:duration="150" android:drawable="@drawable/pic8"/>

</animation-list>

二、通過(guò)自定義顏色實(shí)現(xiàn)

定義res/drawable/progress_color.xml如下:

<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/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="#FFDC35"
android:centerY="0.50"
android:endColor="#CE0000"
android:startColor="#FFFFFF"
android:type="sweep"
android:useLevel="false" />
</shape>

</rotate>

第三種 使用有進(jìn)度的UI圖片:

定義res/drawable/progress_pic.xml如下:

<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/progress1"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="360" />

在Activity 布局中直接使用就可以:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.demo.MainActivity" >

<ProgressBar
android:id="@+id/loading_process_dialog_progressBar"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_gravity="center_horizontal"
android:indeterminate="false"
android:indeterminateDrawable="@anim/loading" />

<ProgressBar
style="?android:attr/progressBarStyleSmall"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginTop="60dp"
android:layout_gravity="center_horizontal"
android:layout_centerInParent="true"
android:indeterminateDrawable="@drawable/progress_small" />

<ProgressBar
android:id="@+id/loading_process_pic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="60dp"
android:indeterminate="false"
android:indeterminateDrawable="@drawable/progress_pic" />

</LinearLayout>

到此這篇關(guān)于Android 實(shí)現(xiàn)自定義圓形進(jìn)度條的三種常用方法的文章就介紹到這了,更多相關(guān)Android 實(shí)現(xiàn)自定義圓形進(jìn)度條內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論

鹤山市| 辽阳市| 沈丘县| 白水县| 望都县| 玛纳斯县| 襄汾县| 中阳县| 马边| 阜新市| 江华| 河北省| 浪卡子县| 武汉市| 陆丰市| 新巴尔虎左旗| 大厂| 万宁市| 湛江市| 抚远县| 西平县| 博客| 唐山市| 中牟县| 绥芬河市| 福建省| 宣汉县| 万荣县| 绥宁县| 郯城县| 昌吉市| 龙陵县| 遂平县| 竹北市| 朔州市| 宜兰县| 左权县| 义乌市| 内黄县| 夹江县| 巴青县|