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


前言

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

【Android珍藏】推薦10個炫酷的開源庫
【開源推薦】進階實戰,從一款音樂播放器開始
2020年有哪些優秀的開源庫呢?本期就為大家帶精選的10個,排名不分先后。

No1. LiquidSwipe

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

1.1如何使用呢?

導入以下Gradle依賴項:

implementation 'com.github.Chrisvin:LiquidSwipe:1.3' 

然后將LiquidSwipeLayout添加為保存fragment布局的容器的根布局:

<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: https://github.com/Chrisvin/LiquidSwipe

No2. Flourish

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

2.1 如何使用?

在build.gradle 中添加如下依賴:

dependencies { implementation "com.github.skydoves:flourish:1.0.0" } 

然后在代碼中,構建布局:

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:https://github.com/skydoves/Flourish

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:https://github.com/gabriel-TheCode/AestheticDialogs

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: circular, linear, random_line, star, sweep & 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: https://github.com/Chrisvin/EasyReveal

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:https://github.com/JorgeCastilloPrz/AndroidColorX

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: https://github.com/Droppers/AnimatedBottomBar

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:https://github.com/lopspower/RateBottomSheet

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" // auto, entering, returning
  app:transformation_fadeMode="in" // in, out, cross, through
  app:transformation_fitMode="auto" // auto, height, width
  app:transformation_pathMode="arc" // arc, linear
>

   <!-- 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: https://github.com/skydoves/TransformationLayout

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: https://github.com/futuredapp/donut

No10. CurveGraphView

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

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

10.1 如何使用?

1、在build.gradle 中添加如下依賴:

dependencies { implementation 'com.github.swapnil1104:CurveGraphView:{current_lib_ver}' } 

2、在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() );); 

3、 提供數據集

PointMap pointMap = new PointMap(); pointMap.addPoint(0, 100); pointMap.addPoint(1, 500); pointMap.addPoint(5, 800); pointMap.addPoint(4, 600); 
10.2 效果圖
效果1 效果2

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

總結

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



作者:依然范特稀西
鏈接:https://www.jianshu.com/p/3f5865109b05
來源:簡書
著作權歸作者所有。商業轉載請聯系作者獲得授權,非商業轉載請注明出處。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM