python与Android有关的库,这15个Android开源库,只有经常逛Github的才知道!
哈嘍,大家好,我是西哥!
又到了大家最喜歡了的環節–
開源庫推薦
,前面為大家推薦了我收藏的一些非常酷的開源庫,受到大家一致好評,還沒看過的,請移步至:
本期又為大家帶來了哪些有趣的庫呢?本期為大家精選了
15
個有趣又有用的開源,
排名不分先后
,一起來看看吧!
1. Coil
Coil是Android上的一個全新的圖片加載框架,它的全名叫做
coroutine image loader
,即協程圖片加載庫。與傳統的圖片加載庫Glide,Picasso或Fresco等相比。該具有輕量(只有大約1500個方法)、快、易于使用、更現代的API等優勢。
它支持GIF和SVG,并且可以執行四個默認轉換:
模糊
,
圓形裁剪
,
灰度
和
圓角
。
示例如下:
imageView.load(“https://www.example.com/image.jpg") {
crossfade(true)
placeholder(R.drawable.image)
transformations(CircleCropTransformation())
}1
2
3
4
5
并且是全用Kotlin編寫,如果你是純Kotlin項目的話,那么這個庫應該是你的首選。
Github地址:https://github.com/coil-kt/coil
2. MultiSearchView
該庫具有一個非常酷的
Search View
動畫!
使用非常簡單,并且可以自定義,你可以在在
styles.xml
下添加自定義樣式。
示例代碼:
android:layout_width="match_parent"
android:layout_height="wrap_content"/>1
2
3
multiSearchView.setSearchViewListener(object : MultiSearchView.MultiSearchViewListener{
override fun onItemSelected(index: Int, s: CharSequence) {
}
override fun onTextChanged(index: Int, s: CharSequence) {
}
override fun onSearchComplete(index: Int, s: CharSequence) {
}
override fun onSearchItemRemoved(index: Int) {
}
})1
2
3
4
5
6
7
8
9
10
11
12
13
14
自定義樣式:
true
true
true
Search
actionSearch
18sp
15
textCapSentences
>#80999999
#0001
2
3
4
5
6
7
8
9
10
11
12
13
14
然后,您應該將樣式設置為
MultiSearchView
下的
app:searchTextStyle
。
Github地址:https://github.com/iammert/MultiSearchView
3. CalendarView
CalendarView
是一個高度可定制化的日歷組件庫,用recycleView實現。
它有如下特性:
單一或范圍選擇
周歷或者月歷模式
邊界日期
自定義日歷視圖
水平或者垂直滾動模式
完全可定制的視圖
該庫的文檔也非常全面,并包含許多示例。此外,還有一個示例應用程序展示了庫的所有功能。
它是用純Kotlin編寫的,并在MIT許可下發布。如果您需要在應用程序中使用日歷視圖,這是一個不錯的選擇。
注意:該庫通過Java 8+ API使用了java.time類,以便向后兼容,因為這些類是在Java 8中添加的。
因此,需要在app的
build.gradle
中添加如下配置:
android {
defaultConfig {
// Required ONLY when setting minSdkVersion to 20 or lower
multiDexEnabled true
}
compileOptions {
// Flag to enable support for the new language APIs
coreLibraryDesugaringEnabled true
// Sets Java compatibility to Java 8
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:'
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Github: https://github.com/kizitonwose/CalendarView
4. Bubble Navigation
FloatingTopBarActivity
TopBarActivity
BottomBarActivity
EqualBottomBarActivity
Bubble Navigation
是一個輕巧的庫,可通過大量自定義選項輕松制作精美的導航欄。
它有很多非常的特性:
針對不同用例的兩種類型的
NavigationViews
:
BubbleNavigationConstraintView
(支持spread
spread
,
inside
, 和
packed
莫斯)
BubbleNavigationLinearView
(允許平均分配,使用權重或packed模式)
高度可定制化
您可以添加小紅點,它具有
BubbleToggleView
來創建新的UI組件,而不僅僅是導航
示例:
android:id="@+id/top_navigation_constraint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="380dp"
android:background="@color/white"
android:elevation="4dp"
android:padding="
12dp"
app:bnc_mode="spread">
android:id="@+id/c_item_rest"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:bt_active="true"
app:bt_colorActive="@color/search_active"
app:bt_colorInactive="@color/search_inactive"
app:bt_icon="@drawable/ic_restaurant"
app:bt_shape="@drawable/transition_background_drawable_restaurant"
app:bt_title="@string/restaurant"
app:bt_padding="@dimen/internal_padding"
app:bt_titlePadding="@dimen/title_padding" />
12
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Github文檔很完善,有很多示例,更多用法和屬性可去Github了解。
Github:https://github.com/gauravk95/bubble-navigation
5. FabFilter
這是一個有趣的項目,它不是一個直接可用的庫,而是一個示例應用程序,展示了
使用
和
不使用
MotionLayout
兩種方式來實現的高級UI動畫。
詳細的實現細節可以看看Medium上的系列文章:
Github:https://github.com/nikhilpanju/FabFilter
6.android-showcase
android-showcase
是一個非常優秀的開源項目,它是一個展示應用程序,展示了如何使用Kotlin和最新的Jetpack 技術棧來開發一個APP。
該項目為您帶來了一系列最佳實踐,工具和解決方案:
100% Kotlin
現代架構 (feature modules, clean architecture, Model-View-ViewModel, Model-View-Intent)
Android Jetpack組件
單Activity模式,使用Navigation導航
看完這個項目,在模塊化,Clean體系結構,測試、設置CI / CD工具,等方面,你將會受到啟發。感謝作者的開源。
Github:https://github.com/igorwojda/android-showcase
7. Croppy
Croppy
是一個Android圖片裁剪庫。
它有很多強大的特性:
雙指縮放
裁剪任意大小
按照長寬比例裁剪
顯示裁剪后的Bitmap
自動居中裁剪
全面的動畫使用體驗
更多使用細節請看Github。
Github: https://github.com/lyrebirdstudio/Croppy
8. RubberPicker
一個炫酷的、有趣的SeekBar動畫庫。
RubberPicker
庫包含
RubberSeekBar
和
RubberRangePicker
,其靈感來自
Cuberto
的
iOS橡膠范圍選擇器
。
使用示例:
布局文件中配置
...
app:minValue="20"
app:maxValue="80"
app:elasticBehavior="cubic"
app:dampingRatio="0.3"
app:stiffness="300"
app:stretchRange="24dp"
app:defaultThumbRadius="16dp"
app:normalTrackWidth="4dp"
app:highlightTrackWidth="8dp"
app:normalTrackColor="#AAAAAA"
app:highlightTrackColor="#BA1F33"
app:defaultThumbInsideColor="#FFF"
app:highlightDefaultThumbOnTouchColor="#CD5D67"/>
...
app:minValue="0"
app:maxValue="100"
app:elasticBehavior="linear"
app:dampingRatio="0.4"
app:stiffness="400"
app:stretchRange="36dp"
app:defaultThumbRadius="16dp"
app:normalTrackWidth="4dp"
app:highlightTrackWidth="8dp"
app:normalTrackColor="#AAAAAA"
app:highlightTrackColor="#BA1F33"
app:defaultThumbInsideColor="#CFCD5D67"
app:highlightDefaultThumbOnTouchColor="#CD5D67"/>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
或者,在代碼中動態配置:
val rubberSeekBar = RubberSeekBar(this)
rubberSeekBar.setMin(20)
rubberSeekBar.setMax(80)
rubberSeekBar.setElasticBehavior(ElasticBehavior.CUBIC)
rubberSeekBar.setDampingRatio(0.4F)
rubberSeekBar.setStiffness(1000F)
rubberSeekBar.
setStretchRange(50f)
rubberSeekBar.setThumbRadius(32f)
rubberSeekBar.setNormalTrackWidth(2f)
rubberSeekBar.setHighlightTrackWidth(4f)
rubberSeekBar.setNormalTrackColor(Color.GRAY)
rubberSeekBar.setHighlightTrackColor(Color.BLUE)
rubberSeekBar.setHighlightThumbOnTouchColor(Color.CYAN)
rubberSeekBar.setDefaultThumbInsideColor(Color.WHITE)
val currentValue = rubberSeekBar.getCurrentValue()
rubberSeekBar.setCurrentValue(currentValue + 10)
rubberSeekBar.setOnRubberSeekBarChangeListener(object : RubberSeekBar.OnRubberSeekBarChangeListener {
override fun onProgressChanged(seekBar: RubberSeekBar, value: Int, fromUser: Boolean) {}
override fun onStartTrackingTouch(seekBar: RubberSeekBar) {}
override fun onStopTrackingTouch(seekBar: RubberSeekBar) {}
})
//Similarly for RubberRangePicker
val rubberRangePicker = RubberRangePicker(this)
rubberRangePicker.setMin(20)
...
rubberRangePicker.setHighlightThumbOnTouchColor(Color.CYAN)
val startThumbValue = rubberRangePicker.getCurrentStartValue()
rubberRangePicker.setCurrentStartValue(startThumbValue + 10)
val endThumbValue = rubberRangePicker.getCurrentEndValue()
rubberRangePicker.setCurrentEndValue(endThumbValue + 10)
rubberRangePicker.setOnRubberRangePickerChangeListener(object: RubberRangePicker.OnRubberRangePickerChangeListener{
override fun onProgressChanged(rangePicker: RubberRangePicker, startValue: Int, endValue: Int, fromUser: Boolean) {}
override fun onStartTrackingTouch(rangePicker: RubberRangePicker, isStartThumb: Boolean) {}
override fun onStopTrackingTouch(rangePicker: RubberRangePicker, isStartThumb: Boolean) {}
})1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
更多、更詳細的使用請看Github。
Github:https://github.com/Chrisvin/RubberPicker
9. Switcher
一個炫酷的Switcher 切換動畫庫,真是的太可愛了,我前面也寫過文章專門介紹過:
它的靈感來自于 Dribble上
Oleg Frolov
的設計。
Github: https://github.com/bitvale/Switcher
10. StfalconImageViewer
StfalconImageViewer
是一個圖片查看庫,
該庫簡單且可定制。它包含一個
全屏圖像查看器
,
具有共享的圖像過渡支持
,
捏合縮放功能
以及
滑動手勢來關閉
手勢。
Github文檔說明了如何使用每個功能。同樣值得注意的是:該庫與所有最受歡迎的圖像處理庫(例如Picasso,Glide等)兼容。
所有可配置項如下:
StfalconImageViewer.Builder(this, images, ::loadImage)
.withStartPosition(startPosition)
.withBackgroundColor(color)
//.withBackgroundColorResource(R.color.color)
.withOverlayView(view)
.withImagesMargin(R.dimen.margin)
//.withImageMarginPixels(margin)
.withContainerPadding(R.dimen.padding)
//.withContainerPadding(R.dimen.paddingStart, R.dimen.paddingTop, R.dimen.paddingEnd, R.dimen.paddingBottom)
//.withContainerPaddingPixels(padding)
//.withContainerPaddingPixels(paddingStart, paddingTop, paddingEnd, paddingBottom)
.withHiddenStatusBar(shouldHideStatusBar)
.allowZooming(isZoomingAllowed)
.allowSwipeToDismiss(isSwipeToDismissAllowed)
.withTransitionFrom(targeImageView)
.withImageChangeListener(::onImageChanged)
.withDismissListener(::onViewerDismissed)
.withDismissListener(::onViewerDismissed)1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
更詳細的使用請看Github。
Github: https://github.com/stfalcon-studio/StfalconImageViewer
11. Broccoli
Broccoli
是一個show View Loading 庫,也就是我常說的
骨架屏
,在內容加載的時候,顯示一個占位符。
該庫帶有很平滑的動畫效果,你可以配合RecyclerView一起使用,等待加載內容時,再也不枯燥了。
示例:
Broccoli broccoli = new Broccoli();
//add the default style placeholder
broccoli.addPlaceholders('activity', 'view_id', 'view_id');
or
//add the default style placeholder
broccoli.addPlaceholders('view1', 'view2', 'view3');
or
//add the custom style placeholder
broccoli.addPlaceholder(new PlaceholderParameter.Builder()
.setView('view')
.setAnimation('scaleAnimation');
.setDrawable(DrawableUtils.createRectangleDrawable(placeHolderColor, 0))
.build());
or
//add the custom style placeholder with gradient animation
broccoli.addPlaceholder(new PlaceholderParameter.Builder()
.setView('view')
.setDrawable(new BroccoliGradientDrawable(Color.parseColor("#DDDDDD"),
Color.parseColor("#CCCCCC"), 0, 1000, new LinearInterpolator())
.build());
broccoli.show();1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
更多使用請看Github。
Github: https://github.com/samlss/Broccoli
12. Orbit MVI
這是一個用于Kotlin和Android的Model-View-Intent (MVI)框架。它的靈感來自Jake Wharton,RxFeedback和Mosby的“Managing State with RxJava”。
根據ReadMe所說:
Orbit在您的redux實現周圍提供了盡可能小的結構,以使其易于使用,但您仍可以使用RxJava的強大功能。
redux系統可能如下所示:
data class State(val total: Int = 0)
data class AddAction(val number: Int)
sealed class SideEffect {
data class Toast(val text: String) : SideEffect()
}
class CalculatorViewModel : OrbitViewModel (State(), {
perform("addition")
.on()
.sideEffect { post(SideEffect.Toast("Adding ${event.number}")) }
.reduce {
currentState.copy(currentState.total + event.number)
}
...
})1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
activity / fragment 中:
// Example of injection using koin, your DI system might differ
private val viewModel by
viewModel()
override fun onCreate() {
...
addButton.setOnClickListener { viewModel.sendAction(AddAction) }
}
override fun onStart() {
viewModel.connect(this, ::handleState, ::handleSideEffect)
}
private fun handleState(state: State) {
...
}
private fun handleSideEffect(sideEffect: SideEffect) {
when (sideEffect) {
is SideEffect.Toast -> toast(sideEffect.text)
}
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
詳細使用請看Github。
Github: https://github.com/babylonhealth/orbit-mvi
13. IndicatorScrollView
IndicatorScrollView
IndicatorScrollView
該庫為
NestedScrollView
添加了邏輯,使它可以在滾動時,更改對指示器進行動態響應。
README文件包含開始項目所需的所有信息,例如如何使用
IndicatorScrollView
,
IndicatorView
和
IndicatorItem
。目前,它的版本為
1.0.2
,是根據Apache 2.0許可發布的。它支持API 16及更高版本。
文檔示例很詳細,更多使用相關請看Github。
Github: https://github.com/skydoves/IndicatorScrollView
14. Cyanea
Cyanea
是一個Android 主題引擎庫。
它允許那你動態更換應用主題,它內置了很多主題如:
Theme.Cyanea.Dark
Theme.Cyanea.Dark.LightActionBar
Theme.Cyanea.Dark.NoActionBar
Theme.Cyanea.Light
Theme.Cyanea.Light.DarkActionBar
Theme.Cyanea.Light.NoActionBar
更多詳細信息請看Github。
Github: https://github.com/jaredrummler/Cyanea
15. Android MotionLayout Carousel
這是一個示例項目,它展示了如何使用
MotionLayout
來實現一個炫酷的輪播圖。
文檔幾乎沒有任何說明,但是如果你最近也在探索MotionLayout,這將是一個很好示例。
Github: https://github.com/faob-dev/MotionLayoutCarousel
總結
以上就是本期的開源項目推薦,如果你也有好玩的、有趣的、強大的開源項目,也可以推薦給西哥,歡迎評論區留言討論。
最后,求個三連!奧利給!
近期熱文
總結
以上是生活随笔為你收集整理的python与Android有关的库,这15个Android开源库,只有经常逛Github的才知道!的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 11--移除重复节点
- 下一篇: Python面试题总结(4)--数据类型