Android依赖库 资源

//FragmentManager切换拥有 commit{} 扩展函数
implementation "androidx.fragment:fragment-ktx:1.6.0"

//Gson
implementation 'com.google.code.gson:gson:2.10.1'
def lifecycle_version = “2.5.1”


//ViewModel
implementation”androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1”
implementation(“androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1”) //Kotlin版本要加括号

//使用 by **ViewModels()**代理
implementation(“androidx.activity:activity-ktx:1.8.2”)
implementation ‘androidx.fragment:fragment-ktx:1.6.0’

//LiveData
implementation”androidx.lifecycle:lifecycle-livedata-ktx:2.6.1”


//viewpager2
implementation ‘androidx.viewpager2:viewpager2:1.0.0’

//recyclerview
implementation ‘androidx.recyclerview:recyclerview:1.3.1’

//Navigation导航
implementation(“androidx.navigation:navigation-fragment-ktx:2.6.0”)
implementation(“androidx.navigation:navigation-ui-ktx:2.6.0”)

//Safe Args
在第1个build.gradle
id ‘androidx.navigation.safeargs’ version ‘2.6.0’ apply false

1
2
3
4
5
6
7
8
9
10
//1
plugins{
//替换classPath
id 'androidx.navigation.safeargs' version '2.7.7' apply false
}

//2
plugins {
id 'androidx.navigation.safeargs.kotlin'
}

//协程 Coroutine
implementation(“org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9”)
//Fragment 和 Activity 默认协程域 lifecycleScope
implementation(‘androidx.lifecycle:lifecycle-runtime-ktx:2.6.1’)
//ViewModel 的协程域 viewModelScope
implementation(‘androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1’)

//Room
implementation(“androidx.room:room-runtime:2.5.2”)
annotationProcessor(“androidx.room:room-compiler:2.5.2”)
kapt(“androidx.room:room-compiler:2.5.2”)
implementation(“androidx.room:room-ktx:2.5.2)
导入插件:id ‘kotlin-kapt’

//Room
implementation(“androidx.room:room-runtime:2.6.1”)
kapt(“androidx.room:room-compiler:2.6.1”)
implementation(“androidx.room:room-ktx:2.6.1”)

//bing

1
2
3
4
5
6
7
8
9
//kts文件中
android{
namespace 'com.example.loginproject'
compileSdk 33

viewBinding {
enable = true
}
}

parcelize 序列化插件
需要在需要序列化的 data class 类上方添加 @Parcelize 序列
并实现: Parcelable

1
2
3
4
5
//2
plugins {
id kotlin-parcelize'
}

//eventbus (在github)
implementation(“org.greenrobot:eventbus:3.3.1”)

如何知道系统已经导入了哪些依赖?
Project -> External Libraries
可以看源代码

即使设计(设计UI)

MAC字体天下

**动画资源: lottiefiles.com **
lottie 动画

  1. 导入 implementation ‘com.airbnb.android:lottie:6.1.0’资源
  2. 创建资源文件夹res —->raw (音频视频 test文件 json文件)—-> file下载导入动画资源
  3. 在 fragment 中添加代码 LottieAnimationView 控件

app:lottie_rawRes=”@raw/delivery” //显示哪个资源
app:lottie_autoPlay=”true” //是否自动播放
app:lottie_loop=”true” //是否循环播放


阿里巴巴矢量图标库:
https://www.iconfont.cn/search

富文本:
在 build.gradle 中加入:
implementation("org.sufficientlysecure:html-textview:4.0")

在 settings.gradle 中加入 jcenter()

1
2
3
4
5
6
7
8
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
jcenter()
}
}

将图片url加载到 ImageView
implementation ‘com.github.bumptech.glide:glide:4.15.1’

需要有网络,在 Manifest文件中(明文):

android:usesCleartextTraffic=”true”

使用方式:
Glide.with(fragment).load(url).into(binding.imageview)

Donate
  • Copyright: Copyright is owned by the author. For commercial reprints, please contact the author for authorization. For non-commercial reprints, please indicate the source.

扫一扫,分享到微信

微信分享二维码
  • Copyrights © 2023-2025 Annie
  • Visitors: | Views:

嘿嘿 请我吃小蛋糕吧~

支付宝
微信