2024年GitHub 上那些优秀Android开源库,这里是Top10!

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文件:

最后,代码中添加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
外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

详情信息请看Github: github.com/Droppers/An…

No7. RateBottomSheet

有时候,为了推广我们的应用,我们需要让用户跳转到应用商店为我们的APP打分,传统的对话框用户体验很不好,而本库则是用BottomSheet来进行提示,它位于底部缩略区域,用户体验很好。

7.1 如何使用呢?

build.gradle 中添加如下依赖:

dependencies {
implementation ‘com.mikhaellopez:ratebottomsheet:1.1.0’
}

然后修改默认的string资源文件来改变显示文案:

Like this App? Do you like using this application? Yes I do Not really

Rate this app
Would you mind taking a moment to rate it? It won’t take more than a minute. Thanks for your support!
Rate it now
Remind me later
No, thanks

代码中使用:

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

</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 如何使用?

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);

更多学习和讨论,欢迎加入我们的知识星球!

点击这里加入我们吧!

群内有许多来自一线的技术大牛,也有在小厂或外包公司奋斗的码农,我们致力打造一个平等,高质量的Android交流圈子,不一定能短期就让每个人的技术突飞猛进,但从长远来说,眼光,格局,长远发展的方向才是最重要的。

p.addPoint(0, 100);
pointMap.addPoint(1, 500);
pointMap.addPoint(5, 800);
pointMap.addPoint(4, 600);

[外链图片转存中…(img-uMRh4HLt-1710326907938)]

更多学习和讨论,欢迎加入我们的知识星球!

点击这里加入我们吧!

群内有许多来自一线的技术大牛,也有在小厂或外包公司奋斗的码农,我们致力打造一个平等,高质量的Android交流圈子,不一定能短期就让每个人的技术突飞猛进,但从长远来说,眼光,格局,长远发展的方向才是最重要的。

这里有2000+小伙伴,让你的学习不寂寞~·

  • 20
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值