每過一段時間呀,我都會給你們帶來一些從Github上收集的一些開源庫,有的是炫酷動效,有的則是實用的工具和類庫。2020年有哪些優秀的開源庫呢?本期就爲你們帶精選的10個,排名不分前後。android
這是一個很棒的ViewPager庫,它在瀏覽ViewPager的不一樣頁面時,顯示波浪的滑動動畫,效果很是炫酷。該庫的USP是觸摸交互的。這意味着在視圖中顯示相似液體的顯示過渡時,應考慮觸摸事件。git
導入如下Gradle依賴項:github
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>
接下來,爲你們介紹下我學習Android時用到的一些資料與視頻,須要的夥伴能夠api
私信我【進階】,我分享給你,也是感謝你們這麼久以來對個人支持。app
330頁Android進階核心筆記
**B站Android進階視頻
去B站搜索,B站帳號:bili_84936792704 便可觀看哦!dom
OK,廢話很少說接下來繼續看文章吧。ide
Flourish提供了一個炫酷的方式來顯示或者隱藏一個佈局,實現方式也很簡單,就是對View或者佈局進行了包裝,經過構建者模式來提供api給上層調用。就像使用dialog同樣,調用show和dissmiss方法來顯示和隱藏。此外,經過這些類,咱們還能夠自定義動畫(正常,加速,反彈),或爲佈局方向設置咱們本身的起點(左上,右下等)。函數
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 效果圖
更多詳細使用請看Github:https://github.com/skydoves/Flourish
這是一個美觀而時尚的AlterDialog庫,目前可支持六種不一樣的對話框,如:
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 DialogConnectify DialogToaster Dialog
Emotion DialogDrake DialogEmoji Dialog
更多詳情使用方法請看Github:https://github.com/gabriel-TheCode/AestheticDialogs
從名字就知道,這是一個提供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 DialogDrake DialogEmoji Dialog
更多詳細使用信息請看Github:https://github.com/Chrisvin/EasyReveal
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 效果圖
這是一個帶動畫的底部導航欄庫。它使你能夠以編程方式以及經過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 效果圖
tab1tab2
有時候,爲了推廣咱們的應用,咱們須要讓用戶跳轉到應用商店爲咱們的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 效果圖
這是一個用於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種方式:
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 效果圖
這個一個能夠展現多個數據集的圓環形控件,具備精細的顆粒控制、間隙功能、動畫選項以及按比例縮放其值的功能。能夠用於項目中的一些數據統計。
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 效果圖
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(0, 100); pointMap.addPoint(1, 500); pointMap.addPoint(5, 800); pointMap.addPoint(4, 600);
10.2 效果圖
效果1
效果2
若是你有其餘須要的話,也能夠在 GitHub 上查看。
以上就是本期的開源庫推薦,別忘了添加到你的收藏夾喲!若是你以爲還不錯,就三連支持一下吧!若是你還有一些有意思的,效果特別炫酷的庫,也歡迎評論區留言推薦,感謝閱讀,祝編碼愉快!
---END---