模擬了 iOS 下載 App 時候的動畫:CircleLoadingView

jopen 8年前發布 | 7K 次閱讀 Android開發 移動開發

模擬了 iOS 下載 App 時候的動畫。

使用說明:

配置方法

Android Studio
  allprojects {
      repositories {
          jcenter()
          maven { url "https://jitpack.io" }
      }
  }

  dependencies {
      compile 'com.github.jhw-dev:CircleLoadingView:v1.3'
  }

Eclipse

我覺得這個時候還在用 Eclipse 做 Android 開發的,要么是大神,要么就該換公司了,不如給我發個簡歷?

使用方法

XML 定義

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.tengchong.android.CircleLoadingView
        android:id="@+id/loading"
        android:layout_width="100dp"
        android:layout_height="100dp"
        app:cl_circleRadius="40dp"
        app:cl_circleStrokeSize="5dp"
        app:cl_fillAnimationDuration="200"
        app:cl_src="@drawable/avatar"/>

</RelativeLayout>

用代碼動態使用以及設定進度方式

        CircleLoadingView loadingView =new CircleLoadingView();
        loadingView.setImageBitmap(
                BitmapFactory.decodeResource(getResources(), R.drawable.avatar));
        loadingView.setPercent(88);

自定義屬性

目前版本比較簡單,僅支持在 XML 文件中自定義,另外,Drawable 只支持 BitmapDrawable,相信你懂的。

  • cl_circleRadius [dimension] --> 中間那個圓的半徑

  • cl_circleStrokeSize [dimension] --> 圓的邊框大小 

  • cl_fillAnimationDuration [integer] --> 最后擴散動畫的時間 

  • cl_src [dimension] --> 背景的 BitmapDrawable 資源


項目地址: https://github.com/jhw-dev/CircleLoadingView

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!