欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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

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

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

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

一、通過幀動畫實現(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>

二、通過自定義顏色實現(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>

第三種 使用有進度的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 實現(xiàn)自定義圓形進度條的三種常用方法的文章就介紹到這了,更多相關(guān)Android 實現(xiàn)自定義圓形進度條內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • Android仿微信通訊錄滑動快速定位功能

    Android仿微信通訊錄滑動快速定位功能

    這篇文章主要介紹了Android仿微信通訊錄滑動快速定位功能,非常不錯,具有參考借鑒價值,需要的朋友可以參考下
    2017-03-03
  • Android圓角按鈕的制作方法

    Android圓角按鈕的制作方法

    這篇文章主要為大家詳細介紹了Android圓角按鈕的制作方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-08-08
  • Android 圖片顯示與屏幕適配的問題

    Android 圖片顯示與屏幕適配的問題

    這篇文章主要介紹了Android 圖片顯示與屏幕適配的問題的相關(guān)資料,Android的分辨率問題是每個Android 開發(fā)者頭疼的問題,那么這里給大家介紹個萬能辦法,需要的朋友可以參考下
    2017-08-08
  • Android直播app送禮物連擊動畫效果(實例代碼)

    Android直播app送禮物連擊動畫效果(實例代碼)

    最近在做公司的直播項目,需要實現(xiàn)一個觀看端連擊送禮物的控件,下面給大家分享實例代碼,需要的的朋友參考下吧
    2017-07-07
  • Android多返回棧技術(shù)

    Android多返回棧技術(shù)

    本文將詳情講解用戶通過系統(tǒng)返回按鈕導航回去的一組頁面,在開發(fā)中被稱為返回棧 (back stack)。多返回棧即一堆 "返回棧",對多返回棧的支持是在 Navigation 2.4.0-alpha01 和 Fragment 1.4.0-alpha01 中開始的,有興趣的話一起參與學習
    2021-08-08
  • Android自定義view實現(xiàn)太極效果實例代碼

    Android自定義view實現(xiàn)太極效果實例代碼

    這篇文章主要介紹了Android自定義view實現(xiàn)太極效果實例代碼的相關(guān)資料,需要的朋友可以參考下
    2017-05-05
  • Android 實現(xiàn)加載大圖片的方法

    Android 實現(xiàn)加載大圖片的方法

    對于超大的圖片,如果不縮放的話,容易導致內(nèi)存溢出。而經(jīng)過處理后,無論多大的圖片,都能夠在手機屏幕上加載出來,不會導致內(nèi)存溢出。本文將對Android 加載大圖片的實現(xiàn)方法進行介紹,下面跟著小編一起來看下吧
    2017-04-04
  • 詳解Android?Flutter如何使用相機實現(xiàn)拍攝照片

    詳解Android?Flutter如何使用相機實現(xiàn)拍攝照片

    在app中使用相機肯定是再平常不過的一項事情了,相機肯定涉及到了底層原生代碼的調(diào)用,那么在flutter中如何快速簡單的使用上相機的功能呢?一起來看看吧
    2023-04-04
  • anroid開發(fā)教程之spinner下拉列表的使用示例

    anroid開發(fā)教程之spinner下拉列表的使用示例

    這篇文章主要介紹了anroid的spinner下拉列表的使用示例,需要的朋友可以參考下
    2014-04-04
  • Android實現(xiàn)粒子爆炸效果的方法

    Android實現(xiàn)粒子爆炸效果的方法

    這篇文章主要介紹了Android實現(xiàn)粒子爆炸效果的方法,實例分析了Android動畫特效的實現(xiàn)技巧,需要的朋友可以參考下
    2015-06-06

最新評論