前言
随着使用AndroidX,哪些我常用的库有些已经不能用了,所以就重新记录以下AndroidX下常用的库。
Android官方
代码语言:javascript复制implementation '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
anko
project - build.gradle
代码语言:javascript复制buildscript {
ext.kotlin_version = '1.1.51'
//....
dependencies {
//...
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
app - build.gradle
代码语言:javascript复制apply 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
下拉刷新
代码语言:javascript复制implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0'
implementation 'com.scwang.smartrefresh:SmartRefreshHeader:1.1.0'
UI框架
QMUI https://qmuiteam.com/android
代码语言:javascript复制implementation 'com.qmuiteam:qmui:2.0.0-alpha10'
图片圆角&背景圆角
图片圆角RoundedImageView
背景圆角FlycoRoundView
//图片圆角
implementation 'com.makeramen:roundedimageview:2.3.0'
//背景圆角
implementation 'com.flyco.roundview:FlycoRoundView_Lib:1.1.4@aar'
消息提示
Toasty
implementation 'com.github.GrenderG:Toasty:1.2.8'
初始化样式
代码语言:javascript复制private 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()
}
弹出窗口
Material Dialogs
implementation 'com.afollestad.material-dialogs:core:0.9.6.0'
设置主题
代码语言:javascript复制MaterialDialog.Builder(this)
.title("温馨提示")
.theme(Theme.LIGHT)
.content("您确定要删除吗?")
.positiveText("确认")
.negativeText("取消")
.onPositive { dialog, which ->
}
.show()
不设置主题的话,在不同的系统下有的是亮色有的是暗色
设置自定义View
代码语言:javascript复制dialog = 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 = "请输入要加入的群号"
Banner
Github:https://github.com/youth5201314/banner
代码语言:javascript复制implementation 'com.youth.banner:banner:2.0.11'
BGABanner-Android
//Banner
implementation 'cn.bingoogolapple:bga-banner:2.2.4@aar'
仿iOS Segment
SHSegmentControl
implementation 'com.7heaven.widgets:segmentcontrol:1.17'
加载HTML的TextView
html-textview
dependencies {
implementation 'org.sufficientlysecure:html-textview:3.5'
}
视频播放器
DKPlayer
代码语言:javascript复制//# 必选,内部默认使用系统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'
功能
权限
https://github.com/yanzhenjie/AndPermission
代码语言:javascript复制implementation 'com.yanzhenjie:permission:2.0.3'
Adapter
BaseRecyclerViewAdapterHelper
implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:3.0.4'
网络请求
Retrofit RX
代码语言:javascript复制//网络请求
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
okhttp-OkGo
fastjson
//网络请求 implementation 'com.lzy.net:okgo:3.0.4' implementation 'com.lzy.net:okrx2:2.0.2' //JSON implementation 'com.alibaba:fastjson:1.2.46'
数据库
android-lite-orm
引用Jar包
事件总线
EventBus
implementation 'org.greenrobot:eventbus:3.1.1'
图片加载
Glide
Glide
代码语言:javascript复制//Glide
implementation 'com.github.bumptech.glide:glide:4.9.0'
Gif加载
android-gif-drawable
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2. '
事件视图绑定
Butterknife
implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
如果编程语言为Kotlin
, 替换 annotationProcessor
为 kapt
代码语言:javascript复制Kotlin项目不建议再使用
implementation "org.jetbrains.anko:anko:$anko_version"
可以使用Anko代替
应用崩溃检测服务
Bugly
implementation 'com.tencent.bugly:crashreport_upgrade:1.4.5'