2020年GitHub 上那些優秀Android開源庫,這裏是Top10!

前言

每過一段時間呀,我都會給你們帶來一些從Github上收集的一些開源庫,有的是炫酷動效,有的則是實用的工具和類庫。之前沒看過或者沒有收藏的同窗,建議先收藏,如下是連接: android

【Android珍藏】推薦10個炫酷的開源庫git

【開源推薦】進階實戰,從一款音樂播放器開始github

2020年有哪些優秀的開源庫呢?本期就爲你們帶精選的10個,排名不分前後。

No1. LiquidSwipe

這是一個很棒的ViewPager庫,它在瀏覽ViewPager的不一樣頁面時,顯示波浪的滑動動畫,效果很是炫酷。該庫的USP是觸摸交互的。這意味着在視圖中顯示相似液體的顯示過渡時,應考慮觸摸事件。web

1.1如何使用呢?

導入如下Gradle依賴項:編程

implementation 'com.github.Chrisvin:LiquidSwipe:1.3'
複製代碼

而後將LiquidSwipeLayout添加爲保存fragment佈局的容器的根佈局:api

<androidx.constraintlayout.widget.ConstraintLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">


    <com.jem.liquidswipe.LiquidSwipeViewPager
        android:id="@+id/viewpager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>


</androidx.constraintlayout.widget.ConstraintLayout>
複製代碼
1.2 效果圖
效果1 效果2

更多詳細使用方法請看Github: github.com/Chrisvin/Li…app

No2. Flourish

Flourish提供了一個炫酷的方式來顯示或者隱藏一個佈局,實現方式也很簡單,就是對View或者佈局進行了包裝,經過構建者模式來提供api給上層調用。就像使用dialog同樣,調用showdissmiss方法來顯示和隱藏。此外,經過這些類,咱們還能夠自定義動畫(正常,加速,反彈),或爲佈局方向設置咱們本身的起點(左上,右下等)。dom

2.1 如何使用?

在build.gradle 中添加以下依賴:編輯器

dependencies {
    implementation "com.github.skydoves:flourish:1.0.0"
}
複製代碼

而後在代碼中,構建佈局:ide

Flourish flourish = new Flourish.Builder(parentLayout)
    // sets the flourish layout for showing and dismissing on the parent layout.
    .setFlourishLayout(R.layout.layout_flourish_main)
    // sets the flourishing animation for showing and dismissing.
    .setFlourishAnimation(FlourishAnimation.BOUNCE)
    // sets the orientation of the starting point.
    .setFlourishOrientation(FlourishOrientation.TOP_LEFT)
    // sets a flourishListener for listening changes.
    .setFlourishListener(flourishListener)
    // sets the flourish layout should be showed on start. 
    .setIsShowedOnStart(false)
    // sets the duration of the flourishing.
    .setDuration(800L)
    .build();
複製代碼

還提供有更簡介的DSL:

val myFlourish = createFlourish(parentLayout) {
  setFlourishLayout(R.layout.layout_flourish_main)
  setFlourishAnimation(FlourishAnimation.ACCELERATE)
  setFlourishOrientation(FlourishOrientation.TOP_RIGHT)
  setIsShowedOnStart(true)
  setFlourishListener {  }
}
複製代碼
2.2 效果圖
效果1 效果2

更多詳細使用請看Github:github.com/skydoves/Fl…

No3. AestheticDialogs

這是一個美觀而時尚的AlterDialog庫,目前可支持六種不一樣的對話框,如:

  • Flash Dialog
  • Connectify Dialog
  • Toaster Dialog
  • Emotion Dialog
  • Drake Dialog
  • Emoji Dialog 而且啊,還提供了暗黑模式的適配。
3.1 如何使用?

build.gradle 中添加以下依賴:

dependencies {
 ...
 implementation 'com.github.gabriel-TheCode:AestheticDialogs:1.1.0'
}
複製代碼

代碼中,顯示不一樣種類的對話框則調用對應的方法就好

Flash:

AestheticDialog.showFlashDialog(this"Your dialog Title""Your message", AestheticDialog.SUCCESS);
AestheticDialog.showFlashDialog(this"Your dialog Title""Your message", AestheticDialog.ERROR);
複製代碼

Connectify:

AestheticDialog.showConnectify(this,"Your message", AestheticDialog.SUCCESS);
AestheticDialog.showConnectify(this"Your message", AestheticDialog.ERROR);

 /// Dark Theme
 AestheticDialog.showConnectifyDark(this,"Your message",AestheticDialog.SUCCESS);
 AestheticDialog.showConnectifyDark(this"Your message", AestheticDialog.ERROR);
複製代碼

Toaster:

 AestheticDialog.showToaster(this"Your dialog Title""Your message", AestheticDialog.ERROR);
AestheticDialog.showToaster(this"Your dialog Title""Your message", AestheticDialog.SUCCESS);
AestheticDialog.showToaster(this"Your dialog Title""Your message", AestheticDialog.WARNING);
 AestheticDialog.showToaster(this"Your dialog Title""Your message", AestheticDialog.INFO);

 /// Dark Theme
 AestheticDialog.showToasterDark(this"Your dialog Title""Your message", AestheticDialog.ERROR);
AestheticDialog.showToasterDark(this"Your dialog Title""Your message", AestheticDialog.SUCCESS);
AestheticDialog.showToasterDark(this"Your dialog Title""Your message", AestheticDialog.WARNING);
 AestheticDialog.showToasterDark(this"Your dialog Title""Your message", AestheticDialog.INFO);
複製代碼

Drake :

 AestheticDialog.showDrake(this, AestheticDialog.SUCCESS);
AestheticDialog.showDrake(this, AestheticDialog.ERROR);
複製代碼

Emoji :

 AestheticDialog.showEmoji(this,"Your dialog Title""Your message", AestheticDialog.SUCCESS);
AestheticDialog.showEmoji(this"Your dialog Title""Your message", AestheticDialog.ERROR);

/// Dark Theme
 AestheticDialog.showEmojiDark(this,"Your dialog Title""Your message", AestheticDialog.SUCCESS);
AestheticDialog.showEmojiDark(this"Your dialog Title""Your message", AestheticDialog.ERROR);
複製代碼

Emotion :

 AestheticDialog.showEmotion(this,"Your dialog Title""Your message", AestheticDialog.SUCCESS);
AestheticDialog.showEmotion(this"Your dialog Title""Your message", AestheticDialog.ERROR);
複製代碼

Rainbow :

 AestheticDialog.showRainbow(this,"Your dialog Title""Your message", AestheticDialog.SUCCESS);
 AestheticDialog.showRainbow(this,"Your dialog Title""Your message", AestheticDialog.ERROR);
 AestheticDialog.showRainbow(this,"Your dialog Title""Your message", AestheticDialog.WARNING);
AestheticDialog.showRainbow(this,"Your dialog Title""Your message", AestheticDialog.INFO);
複製代碼
3.2 效果以下
Flash Dialog Connectify Dialog Toaster Dialog
d1.gif d2.gif d3.gif
Emotion Dialog Drake Dialog Emoji Dialog
d4.gif d5.gif d6.gif

更多詳情使用方法請看Github:github.com/gabriel-The…

N4. EasyReveal

從名字就知道,這是一個提供reveal動畫效果的庫,它的厲害之處在於能夠提供不一樣尺寸、不一樣形狀的reveal動畫,而且還能夠在定義它在屏幕任意位置開始和結束動畫。

4.1 如何使用?

build.gradle 中添加以下依賴:

dependencies {
 ...
 implementation 'com.github.Chrisvin:EasyReveal:1.2'
}
複製代碼

而後,xml中,須要添加顯示或者隱藏動畫的View應該包裹在EasyRevealLinearLayout中:

<com.jem.easyreveal.layouts.EasyRevealLinearLayout
    ...
    app:clipPathProvider="star" // possible values: circularlinearrandom_linestarsweep & wave
    app:revealAnimationDuration="2000"
    app:hideAnimationDuration="1500" >


    <!-- The views to be revealed/hidden go here -->

</com.jem.easyreveal.layouts.EasyRevealLinearLayout>
<!-- Similarly for com.jem.easyreveal.layouts.EasyRevealConstraintLayout & com.jem.easyreveal.layouts.EasyRevealFrameLayout -->
複製代碼

也能夠在代碼中添加:

val revealLayout = EasyRevealLinearLayout(this)
// Set the ClipPathProvider that is used to clip the view for reveal animation
revealLayout.clipPathProvider = StarClipPathProvider(numberOfPoints = 6)
// Set the duration taken for reveal animation
revealLayout.revealAnimationDuration = 1500
// Set the duration taken for hide animation
revealLayout.hideAnimationDuration = 2000
// Set listener to get updates during reveal/hide animation
revealLayout.onUpdateListener = object: RevealLayout.OnUpdateListener {
    override fun onUpdate(percent: Float) {
        Toast.makeText(this@MainActivity"Revealed percent: $percent", Toast.LENGTH_SHORT).show()
    }
}
// Start reveal animation
revealLayout.reveal()
// Start hide animation
revealLayout.hide()
複製代碼
4.2效果圖
Emotion Dialog Drake Dialog Emoji Dialog

更多詳細使用信息請看Github: github.com/Chrisvin/Ea…

No5. Android ColorX

Android ColorX 以Kotlin 擴展函數的形式提供了一些重要的獲取顏色的方法。 經過提供不一樣顏色格式(RGB,HSV,CYMK等)的轉換功能,它使開發變得更加輕鬆。該庫的USP具備如下功能:

  • 顏色的不一樣陰影和色調。
  • 較深和較淺的陰影。
  • 顏色的補碼
5.1 如何使用?

build.gradle 中添加以下依賴:

dependencies {
    implementation 'me.jorgecastillo:androidcolorx:0.2.0'
}
複製代碼

在代碼中,一系列的轉換方法:

val color = Color.parseColor("#e91e63")

val rgb = color.asRgb()
val argb = color.asArgb()
val hex = color.asHex()
val hsl = color.asHsl()
val hsla = color.asHsla()
val hsv = color.asHsv()
val cmyk = color.asCmyk()

val colorHsl = HSLColor(hue = 210f, saturation = 0.5f, lightness = 0.5f)

val colorInt = colorHsl.asColorInt()
val rgb = colorHsl.asRgb()
val argb = colorHsl.asArgb()
val hex = colorHsl.asHex()
val cmyk = colorHsl.asCmyk()
val hsla = colorHsl.asHsla()
val hsv = colorHsl.asHsv()
複製代碼
5.2 效果圖

更多詳細使用信息請看Github:github.com/JorgeCastil…

No6. AnimatedBottomBar

這是一個帶動畫的底部導航欄庫。它使你能夠以編程方式以及經過XML添加和刪除選項卡。此外,咱們能夠輕鬆地從BottomBar攔截選項卡。限制訪問應用程序導航中的高級區域時,「攔截」標籤很是有用。流暢的動畫提供了許多自定義選項,從動畫插值器到設置波紋效果。

6.1 如何使用?

build.gradle 中添加以下依賴:

dependencies {
  implementation 'nl.joery.animatedbottombar:library:1.0.8'
}
複製代碼

在xml文件中添加AnimatedBottomBar和自定義屬性

<nl.joery.animatedbottombar.AnimatedBottomBar
    android:id="@+id/bottom_bar"
    android:background="#FFF"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:abb_selectedTabType="text"
    app:abb_indicatorAppearance="round"
    app:abb_indicatorMargin="16dp"
    app:abb_indicatorHeight="4dp"
    app:abb_tabs="@menu/tabs"
    app:abb_selectedIndex="1" />

複製代碼

res/menu目錄下定義tabs.xml文件:

<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:id="@+id/tab_home"
        android:icon="@drawable/home"
        android:title="@string/home" />

    <item
        android:id="@+id/tab_alarm"
        android:icon="@drawable/alarm"
        android:title="@string/alarm" />

    <item
        android:id="@+id/tab_bread"
        android:icon="@drawable/bread"
        android:title="@string/bread" />

    <item
        android:id="@+id/tab_cart"
        android:icon="@drawable/cart"
        android:title="@string/cart" />

</menu>
複製代碼

最後,代碼中添加tab

// Creating a tab by passing values
val bottomBarTab1 = AnimatedBottomBar.createTab(drawable, "Tab 1")

// Creating a tab by passing resources
val bottomBarTab2 = AnimatedBottomBar.createTab(R.drawable.ic_home, R.string.tab_2, R.id.tab_home)
複製代碼
6.2 效果圖
tab1 tab2
tab1.gif tab2.gif

詳情信息請看Github: github.com/Droppers/An…

No7. RateBottomSheet

有時候,爲了推廣咱們的應用,咱們須要讓用戶跳轉到應用商店爲咱們的APP打分,傳統的對話框用戶體驗很很差,而本庫則是用BottomSheet來進行提示,它位於底部縮略區域,用戶體驗很好。

7.1 如何使用呢?

build.gradle 中添加以下依賴:

dependencies {
implementation 'com.mikhaellopez:ratebottomsheet:1.1.0'
}
複製代碼

而後修改默認的string資源文件來改變顯示文案:

<resources>
    <string name="rate_popup_ask_title">Like this App?</string>
    <string name="rate_popup_ask_message">Do you like using this application?</string>
    <string name="rate_popup_ask_ok">Yes I do</string>
    <string name="rate_popup_ask_no">Not really</string>

    <string name="rate_popup_title">Rate this app</string>
    <string name="rate_popup_message">Would you mind taking a moment to rate it? It won\'t take more than a minute. Thanks for your support!</string>
    <string name="rate_popup_ok">Rate it now</string>
    <string name="rate_popup_later">Remind me later</string>
    <string name="rate_popup_no">No, thanks</string>
</resources>
複製代碼

代碼中使用:

RateBottomSheetManager(this)
    .setInstallDays(1// 3 by default
    .setLaunchTimes(2// 5 by default
    .setRemindInterval(1// 2 by default
    .setShowAskBottomSheet(false// True by default
    .setShowLaterButton(false// True by default
    .setShowCloseButtonIcon(false// True by default
    .monitor()

// Show bottom sheet if meets conditions
// With AppCompatActivity or Fragment
RateBottomSheet.showRateBottomSheetIfMeetsConditions(this)
複製代碼
7.2 效果圖

更多詳情請看Github:github.com/lopspower/R…

No8. TransformationLayout

這是一個用於Activity或者Fragment 以及View切換的過渡動畫庫,效果很是炫,它使用Material Design的運動系統過渡模式來建立變形動畫。該庫提供了用於綁定目標視圖,設置淡入淡出和路徑運動方向以及許多其餘自定義選項的屬性。

8.1 如何使用?

build.gradle 中添加以下依賴:

dependencies {
    implementation "com.github.skydoves:transformationlayout:1.0.4"
}
複製代碼

而後,須要將咱們須要添加過渡動畫的View包裹到 TransformationLayout:

<com.skydoves.transformationlayout.TransformationLayout
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  app:transformation_targetView="@+id/my_cardView" // sets a target view.
  app:transformation_duration="450" // sets a duration of the transformation.
  app:transformation_direction="auto" // autoenteringreturning
  app:transformation_fadeMode="in" // inoutcrossthrough
  app:transformation_fitMode="auto" // autoheightwidth
  app:transformation_pathMode="arc" // arclinear
>


   <!-- other views -->

</com.skydoves.transformationlayout.TransformationLayout>
複製代碼

好比咱們要將一個fab 過渡到一個card卡片,佈局以下:

<com.skydoves.transformationlayout.TransformationLayout
    android:id="@+id/transformationLayout"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:transformation_duration="550"
    app:transformation_targetView="@+id/myCardView">


  <com.google.android.material.floatingactionbutton.FloatingActionButton
      android:id="@+id/fab"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:backgroundTint="@color/colorPrimary"
      android:src="@drawable/ic_write"/>

</com.skydoves.transformationlayout.TransformationLayout>

<com.google.android.material.card.MaterialCardView
    android:id="@+id/myCardView"
    android:layout_width="240dp"
    android:layout_height="312dp"
    android:layout_marginLeft="30dp"
    android:layout_marginTop="30dp"
    app:cardBackgroundColor="@color/colorPrimary" />

複製代碼

重點來了,綁定視圖,將一個targetView綁定到TransformationLayout有2種方式:

  • 經過在xml中指定屬性:
app:transformation_targetView="@+id/myCardView"
複製代碼
  • 在代碼中綁定
transformationLayout.bindTargetView(myCardView)
複製代碼

當咱們點擊fab時,在監聽器中調用startTransform()開始過渡動畫,finishTransform()開始結束動畫。

// start transformation when touching the fab.
fab.setOnClickListener {
  transformationLayout.startTransform()
}

// finish transformation when touching the myCardView.
myCardView.setOnClickListener {
  transformationLayout.finishTransform()
}
複製代碼
8.2 效果圖

更多使用方式請看Github: github.com/skydoves/Tr…

No9. Donut

這個一個能夠展現多個數據集的圓弧形控件,具備精細的顆粒控制、間隙功能、動畫選項以及按比例縮放其值的功能。能夠用於項目中的一些數據統計。

9.1 如何使用?

build.gradle 中添加以下依賴:

dependencies {
    implementation("app.futured.donut:library:$version")
}
複製代碼

而後在佈局文件中添加View:

<app.futured.donut.DonutProgressView
    android:id="@+id/donut_view"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:donut_bgLineColor="@color/cloud"
    app:donut_gapWidth="20"
    app:donut_gapAngle="270"
    app:donut_strokeWidth="16dp"/>

複製代碼

而後在代碼中設置數據:

val dataset1 = DonutDataset(
    name = "dataset_1",
    color = Color.parseColor("#FB1D32"),
    amount = 1f
)

val dataset2 = DonutDataset(
    name = "dataset_2",
    color = Color.parseColor("#FFB98E"),
    amount = 1f
)

donut_view.cap = 5f
donut_view.submitData(listOf(dataset1, dataset2))
複製代碼
9.2 效果圖

更多用法請看Github: github.com/futuredapp/…

No10. CurveGraphView

CurveGraphView 是一個帶有炫酷動畫統計圖表庫,除了性能出色並具備許多樣式選項以外,該庫還支持單個平面內的多個線圖。

多個折線圖對於比較不一樣股票,共同基金,加密貨幣等的價格很是有用。

10.1 如何使用?

一、在build.gradle 中添加以下依賴:

dependencies {
    implementation 'com.github.swapnil1104:CurveGraphView:{current_lib_ver}'
}
複製代碼

二、在xml文件中添加布局:

 <com.broooapps.graphview.CurveGraphView
        android:id="@+id/cgv"
        android:layout_width="0dp"
        android:layout_height="250dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

複製代碼

而後在代碼中添加各類配置項

curveGraphView = findViewById(R.id.cgv);

curveGraphView.configure(
        new CurveGraphConfig.Builder(this)
                .setAxisColor(R.color.Blue)                                             // Set X and Y axis line color stroke.
                .setIntervalDisplayCount(7)                                             // Set number of values to be displayed in X ax
                .setGuidelineCount(2)                                                   // Set number of background guidelines to be shown.
                .setGuidelineColor(R.color.GreenYellow)                                 // Set color of the visible guidelines.
                .setNoDataMsg(" No Data ")                                              // Message when no data is provided to the view.
                .setxAxisScaleTextColor(R.color.Black)                                  // Set X axis scale text color.
                .setyAxisScaleTextColor(R.color.Black)                                  // Set Y axis scale text color
                .build()
        ););
複製代碼

三、 提供數據集

PointMap pointMap = new PointMap();
        pointMap.addPoint(0100);
        pointMap.addPoint(1500);
        pointMap.addPoint(5800);
        pointMap.addPoint(4600);
複製代碼
10.2 效果圖
效果1 效果2

更多詳細使用方式請看Github: github.com/swapnil1104…

總結

以上就是本期的開源庫推薦,別忘了添加到你的收藏夾喲!若是你以爲還不錯,就三連支持一下吧!若是你還有一些有意思的,效果特別炫酷的庫,也歡迎評論區留言推薦,感謝閱讀,祝編碼愉快!

相關文章
相關標籤/搜索