随着使用AndroidX,哪些我常用的库有些已经不能用了,所以就重新记录以下AndroidX下常用的库。
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'
project - build.gradle
buildscript {
ext.kotlin_version = '1.1.51'
//....
dependencies {
//...
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
app - build.gradle
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"
}
implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0'
implementation 'com.scwang.smartrefresh:SmartRefreshHeader:1.1.0'
QMUI https://qmuiteam.com/android
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'
implementation 'com.github.GrenderG:Toasty:1.2.8'
初始化样式
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()
}
implementation 'com.afollestad.material-dialogs:core:0.9.6.0'
设置主题
MaterialDialog.Builder(this)
.title("温馨提示")
.theme(Theme.LIGHT)
.content("您确定要删除吗?")
.positiveText("确认")
.negativeText("取消")
.onPositive { dialog, which ->
}
.show()
不设置主题的话,在不同的系统下有的是亮色有的是暗色
设置自定义View
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 = "请输入要加入的群号"
Github:https://github.com/youth5201314/banner
implementation 'com.youth.banner:banner:2.0.11'
//Banner
implementation 'cn.bingoogolapple:bga-banner:2.2.4@aar'
implementation 'com.7heaven.widgets:segmentcontrol:1.17'
dependencies {
implementation 'org.sufficientlysecure:html-textview:3.5'
}
DKPlayer
//# 必选,内部默认使用系统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
implementation 'com.yanzhenjie:permission:2.0.3'
implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:3.0.4'
Retrofit+RX
//网络请求
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' 引用Jar包
implementation 'org.greenrobot:eventbus:3.1.1'
Glide
//Glide
implementation 'com.github.bumptech.glide:glide:4.9.0'
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.+'
implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
如果编程语言为Kotlin
, 替换 annotationProcessor
为 kapt
Kotlin项目不建议再使用
implementation "org.jetbrains.anko:anko:$anko_version"
可以使用Anko代替
implementation 'com.tencent.bugly:crashreport_upgrade:1.4.5'