前言

随着使用AndroidX,哪些我常用的库有些已经不能用了,所以就重新记录以下AndroidX下常用的库。

Android官方1

2

3

4

5

6

7

8implementation 'androidx.appcompat:appcompat:1.1.0'

implementation 'androidx.core:core-ktx:1.3.0'

implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

implementation 'androidx.legacy:legacy-support-v4:1.0.0'

implementation 'androidx.multidex:multidex:2.0.1'

implementation 'androidx.multidex:multidex-instrumentation:2.0.0'

androidTestImplementation 'androidx.test.ext:junit:1.1.1'

androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

我的常用组件

Kotlin

Kotlin & anko

project - build.gradle

1

2

3

4

5

6

7

8buildscript {

ext.kotlin_version = '1.1.51'

//....

dependencies {

//...

classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

}

}

app - build.gradle

1

2

3

4

5

6

7

8apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

apply plugin: 'kotlin-kapt'

dependencies {

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

implementation "org.jetbrains.anko:anko:$anko_version"

}

UI

下拉刷新1

2implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0'

implementation 'com.scwang.smartrefresh:SmartRefreshHeader:1.1.0'

UI框架1implementation 'com.qmuiteam:qmui:2.0.0-alpha10'

图片圆角&背景圆角1

2

3

4//图片圆角

implementation 'com.makeramen:roundedimageview:2.3.0'

//背景圆角

implementation 'com.flyco.roundview:FlycoRoundView_Lib:1.1.4@aar'

消息提示1implementation 'com.github.GrenderG:Toasty:1.2.8'

初始化样式

1

2

3

4

5

6

7

8

9

10

11private fun initToast() {

Toasty.Config.getInstance()

.setTextColor(ZJColor.white)

.setWarningColor(ZJColor.black_tran)

.setSuccessColor(ZJColor.black_tran)

.setInfoColor(ZJColor.black_tran)

.setErrorColor(ZJColor.black_tran)

.setTextSize(14)

.setToastTypeface(Typeface.MONOSPACE)

.apply()

}

弹出窗口1implementation 'com.afollestad.material-dialogs:core:0.9.6.0'

​ 设置主题

1

2

3

4

5

6

7

8

9MaterialDialog.Builder(this)

.title("温馨提示")

.theme(Theme.LIGHT)

.content("您确定要删除吗?")

.positiveText("确认")

.negativeText("取消")

.onPositive { dialog, which ->

}

.show()

不设置主题的话,在不同的系统下有的是亮色有的是暗色

设置自定义View

1

2

3

4

5

6

7

8

9

10

11

12dialog = MaterialDialog.Builder(this)

.theme(Theme.LIGHT)

.title("加入群")

.customView(R.layout.s_dialog_input, true)

.positiveText("加入")

.negativeText("取消")

.onPositive { dialog, which ->

}

.show()

(dialog?.findViewById(R.id.input_edittext) as EditText).hint = "请输入要加入的群号"

Banner1implementation 'com.youth.banner:banner:2.0.11'

1

2//Banner

implementation 'cn.bingoogolapple:bga-banner:2.2.4@aar'

仿iOS Segment1implementation 'com.7heaven.widgets:segmentcontrol:1.17'

加载HTML的TextView1

2

3dependencies {

implementation 'org.sufficientlysecure:html-textview:3.5'

}

视频播放器

DKPlayer

1

2

3

4

5

6//# 必选,内部默认使用系统mediaplayer进行解码

implementation 'com.github.dueeeke.dkplayer:dkplayer-java:3.2.6'

//# 可选,包含StandardVideoController的实现

implementation 'com.github.dueeeke.dkplayer:dkplayer-ui:3.2.6'

//# 可选,使用exoplayer进行解码

implementation 'com.github.dueeeke.dkplayer:player-exo:3.2.6'

功能

权限1implementation 'com.yanzhenjie:permission:2.0.3'

Adapter1implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:3.0.4'

网络请求

Retrofit+RX

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18//网络请求

implementation 'io.reactivex.rxjava2:rxjava:2.1.10'

implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'

implementation 'io.reactivex:rxandroid:1.2.1'

implementation 'com.jakewharton.rxbinding2:rxbinding:2.1.1'

implementation 'com.squareup.retrofit2:retrofit:2.6.0'

implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'

implementation 'com.squareup.okhttp3:logging-interceptor:4.0.1'

implementation 'com.squareup.retrofit2:converter-gson:2.3.0'

implementation 'com.trello.rxlifecycle2:rxlifecycle:2.2.1'

implementation 'com.trello.rxlifecycle2:rxlifecycle-components:2.2.1'

implementation 'com.trello.rxlifecycle2:rxlifecycle-android:2.2.1'

//AutoDispose解决RxJava内存泄漏

implementation 'com.uber.autodispose:autodispose:0.7.0'

implementation 'com.uber.autodispose:autodispose-android:0.7.0'

implementation 'com.uber.autodispose:autodispose-android-archcomponents:0.7.0'

OkGo+FastJson

1

2

3

4

5//网络请求

implementation 'com.lzy.net:okgo:3.0.4'

implementation 'com.lzy.net:okrx2:2.0.2'

//JSON

implementation 'com.alibaba:fastjson:1.2.46'

数据库1引用Jar包

事件总线1implementation 'org.greenrobot:eventbus:3.1.1'

图片加载

Glide

1

2//Glide

implementation 'com.github.bumptech.glide:glide:4.9.0'

Gif加载1implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.+'

事件视图绑定1

2implementation 'com.jakewharton:butterknife:8.8.1'

annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'

如果编程语言为Kotlin, 替换 annotationProcessor 为 kapt

Kotlin项目不建议再使用

1implementation "org.jetbrains.anko:anko:$anko_version"

可以使用Anko代替

应用崩溃检测服务1implementation 'com.tencent.bugly:crashreport_upgrade:1.4.5'

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐