跳转至

概述

Accompanist :Jetpack Compose 的工具包

官方地址

https://google.github.io/accompanist/

https://github.com/google/accompanist

Maven Central

功能

Insets

设置 WindowsInsets

配置
repositories {
    mavenCentral()
}

dependencies {
    implementation "com.google.accompanist:accompanist-insets:<version>"
    // If using insets-ui
    implementation "com.google.accompanist:accompanist-insets-ui:<version>"
}

System UI Controller

可以设置系统状态栏的颜色和显示隐藏

配置
repositories {
    mavenCentral()
}

dependencies {
    implementation "com.google.accompanist:accompanist-systemuicontroller:<version>"
}

AppCompat Theme Adapter

引用 AppCompat 的 xml 形式主题

配置
repositories {
    mavenCentral()
}

dependencies {
    implementation "com.google.accompanist:accompanist-appcompat-theme:<version>"
}

Pager

类似 Android 里面的 ViewPager

配置
repositories {
    mavenCentral()
}

dependencies {
    implementation "com.google.accompanist:accompanist-pager:<version>"

    // If using indicators, also depend on 
    implementation "com.google.accompanist:accompanist-pager-indicators:<version>"
}

Permissions

权限请求

配置
repositories {
    mavenCentral()
}

dependencies {
    implementation "com.google.accompanist:accompanist-permissions:<version>"
}

Placeholder

更简单的使用数据未加载时的占位符

配置
repositories {
    mavenCentral()
}

dependencies {
    // If you're using Material, use accompanist-placeholder-material
    implementation "com.google.accompanist:accompanist-placeholder-material:<version>"

    // Otherwise use the foundation version
    implementation "com.google.accompanist:accompanist-placeholder:<version>"
}

Flow Layouts

Flexbox-line 布局

配置
repositories {
    mavenCentral()
}

dependencies {
    implementation "com.google.accompanist:accompanist-flowlayout:<version>"
}

导航动画

配置
repositories {
    mavenCentral()
}

dependencies {
    implementation "com.google.accompanist:accompanist-navigation-animation:<version>"
}

提供Compose Material 支持,比如 model bottom sheets

配置
repositories {
    mavenCentral()
}

dependencies {
    implementation "com.google.accompanist:accompanist-navigation-material:<version>"
}

Drawable Painter

更灵活的使用 Android Drabables

配置
repositories {
    mavenCentral()
}

dependencies {
    implementation "com.google.accompanist:accompanist-drawablepainter:<version>"
}

Swipe to Refresh

下拉刷新,类似 Android 的 SwipeRefreshLayout

配置
repositories {
    mavenCentral()
}

dependencies {
    implementation "com.google.accompanist:accompanist-swiperefresh:<version>"
}

WebView

repositories { mavenCentral() }

dependencies { implementation “com.google.accompanist:accompanist-webview:” }

视频教程