Top Related Projects
Modular and customizable Material Design UI components for Android
Render After Effects animations natively on Android and iOS, Web, and React Native
A curated list of awesome Android UI/UX libraries
π A beautiful, fluid, and extensible dialogs API for Kotlin & Android.
ζι« Android UI εΌεζηη UI εΊ
:balloon: Modernized and sophisticated tooltips, fully customizable with an arrow and animations for Android.
Quick Overview
Google Accompanist is a collection of extension libraries for Jetpack Compose, Android's modern toolkit for building native UI. It provides a set of utilities and components to enhance the development experience with Compose, offering solutions for common UI patterns and functionalities.
Pros
- Simplifies implementation of complex UI components in Jetpack Compose
- Officially maintained by Google, ensuring compatibility and regular updates
- Modular architecture allows developers to include only needed components
- Provides consistent solutions for common Android UI challenges
Cons
- Adds additional dependencies to the project
- May increase app size if many modules are included
- Learning curve for developers new to Jetpack Compose
- Some components may become obsolete as Jetpack Compose evolves
Code Examples
- Using Pager with Accompanist:
import com.google.accompanist.pager.ExperimentalPagerApi
import com.google.accompanist.pager.HorizontalPager
import com.google.accompanist.pager.rememberPagerState
@OptIn(ExperimentalPagerApi::class)
@Composable
fun PagerExample() {
val pagerState = rememberPagerState()
HorizontalPager(
count = 5,
state = pagerState
) { page ->
Text("Page: $page")
}
}
- Implementing Swipe-to-Refresh:
import com.google.accompanist.swiperefresh.SwipeRefresh
import com.google.accompanist.swiperefresh.rememberSwipeRefreshState
@Composable
fun SwipeRefreshExample() {
var refreshing by remember { mutableStateOf(false) }
SwipeRefresh(
state = rememberSwipeRefreshState(isRefreshing = refreshing),
onRefresh = { refreshing = true }
) {
// Content
}
}
- Using System UI Controller:
import com.google.accompanist.systemuicontroller.rememberSystemUiController
@Composable
fun SystemUiExample() {
val systemUiController = rememberSystemUiController()
SideEffect {
systemUiController.setSystemBarsColor(
color = Color.Transparent,
darkIcons = true
)
}
}
Getting Started
To use Google Accompanist in your project, add the desired modules to your app's build.gradle
file:
dependencies {
implementation "com.google.accompanist:accompanist-pager:0.28.0"
implementation "com.google.accompanist:accompanist-swiperefresh:0.28.0"
implementation "com.google.accompanist:accompanist-systemuicontroller:0.28.0"
// Add other modules as needed
}
Then, import and use the desired components in your Compose functions as shown in the code examples above.
Competitor Comparisons
Modular and customizable Material Design UI components for Android
Pros of Material Components for Android
- Comprehensive set of pre-built UI components following Material Design guidelines
- Official Google library with extensive documentation and support
- Seamless integration with Android's native UI elements
Cons of Material Components for Android
- Larger library size, potentially increasing app size
- Less flexibility for customization compared to Accompanist
- Primarily focused on traditional Android Views, not Jetpack Compose
Code Comparison
Material Components for Android:
MaterialButton(
onClick = { /* Handle click */ },
text = "Click me"
)
Accompanist:
Button(
onClick = { /* Handle click */ },
colors = ButtonDefaults.buttonColors(backgroundColor = MaterialTheme.colors.primary)
) {
Text("Click me")
}
Summary
Material Components for Android offers a comprehensive set of pre-built UI components following Material Design guidelines, while Accompanist provides a collection of libraries to complement Jetpack Compose. Material Components is more suitable for traditional Android development, while Accompanist is tailored for Compose-based projects. The choice between the two depends on the project's requirements, target platform, and development approach.
Render After Effects animations natively on Android and iOS, Web, and React Native
Pros of Lottie-Android
- Specialized for complex animations: Lottie excels in rendering intricate, high-quality animations exported from After Effects
- Cross-platform support: Works across Android, iOS, and web platforms
- Large ecosystem: Extensive library of pre-made animations available on LottieFiles
Cons of Lottie-Android
- Limited scope: Focused solely on animations, while Accompanist offers a broader range of UI utilities
- Steeper learning curve: Requires familiarity with After Effects for creating custom animations
- Potentially larger app size: May increase APK size due to animation assets
Code Comparison
Lottie-Android:
val compositionResult = rememberLottieComposition(LottieCompositionSpec.Asset("animation.json"))
LottieAnimation(
composition = compositionResult.value,
iterations = LottieConstants.IterateForever,
)
Accompanist:
val pagerState = rememberPagerState()
HorizontalPager(
count = 5,
state = pagerState,
) { page ->
Text("Page: $page")
}
This comparison highlights the specialized nature of Lottie-Android for animations, while Accompanist provides a broader set of UI utilities for Jetpack Compose. The code snippets demonstrate the different focus areas of each library.
A curated list of awesome Android UI/UX libraries
Pros of awesome-android-ui
- Comprehensive collection of UI libraries and components
- Covers a wide range of UI elements and design patterns
- Community-driven with contributions from various developers
Cons of awesome-android-ui
- Not actively maintained, with less frequent updates
- Lacks official Google support and integration with Jetpack Compose
- May include outdated or deprecated libraries
Code Comparison
awesome-android-ui:
<com.github.johnpersano.supertoasts.SuperActivityToast
android:id="@+id/super_toast"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
accompanist:
@Composable
fun SystemUiController(content: @Composable () -> Unit) {
val systemUiController = rememberSystemUiController()
SideEffect {
systemUiController.setSystemBarsColor(Color.Transparent)
}
content()
}
Summary
awesome-android-ui is a curated list of Android UI libraries, offering a wide variety of components and design patterns. It's community-driven and covers many UI elements. However, it may include outdated libraries and lacks official Google support.
accompanist, on the other hand, is an official Google project focused on Jetpack Compose. It provides a set of extension libraries for Compose, ensuring better integration and up-to-date compatibility with the latest Android development practices.
π A beautiful, fluid, and extensible dialogs API for Kotlin & Android.
Pros of Material Dialogs
- Focused specifically on creating and customizing dialogs
- Extensive documentation and examples
- Supports both Kotlin and Java
Cons of Material Dialogs
- Limited to dialog-related functionality
- May require additional dependencies for more complex use cases
Code Comparison
Material Dialogs:
MaterialDialog(this).show {
title(R.string.your_title)
message(R.string.your_message)
positiveButton(R.string.agree)
negativeButton(R.string.disagree)
}
Accompanist:
@Composable
fun DialogExample() {
AlertDialog(
onDismissRequest = { /* ... */ },
title = { Text("Your Title") },
text = { Text("Your Message") },
confirmButton = { Button(onClick = { /* ... */ }) { Text("Agree") } },
dismissButton = { Button(onClick = { /* ... */ }) { Text("Disagree") } }
)
}
Summary
Material Dialogs is a specialized library for creating and customizing dialogs in Android applications. It offers extensive documentation and examples, making it easy to implement various dialog types. However, its focus is limited to dialogs, which may require additional libraries for other UI components.
Accompanist, on the other hand, is a collection of Jetpack Compose libraries that cover a wider range of UI components and functionalities. While it may not have as extensive dialog-specific features as Material Dialogs, it provides a more comprehensive set of tools for modern Android development using Compose.
ζι« Android UI εΌεζηη UI εΊ
Pros of QMUI_Android
- Comprehensive UI component library with a wide range of pre-built elements
- Extensive documentation and examples in Chinese, beneficial for Chinese developers
- Longer development history and more mature codebase
Cons of QMUI_Android
- Limited support for Jetpack Compose, primarily focused on traditional Android Views
- Less frequent updates compared to Accompanist
- Steeper learning curve due to the large number of components and features
Code Comparison
QMUI_Android (XML-based layout):
<com.qmuiteam.qmui.widget.QMUITopBar
android:id="@+id/topbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:qmui_topbar_title="QMUI TopBar" />
Accompanist (Jetpack Compose):
TopAppBar(
title = { Text("Accompanist TopAppBar") },
backgroundColor = MaterialTheme.colors.primarySurface
)
QMUI_Android focuses on traditional Android Views with XML layouts, while Accompanist is designed for Jetpack Compose, offering more modern and declarative UI components. QMUI_Android provides a broader range of UI elements but may require more setup, whereas Accompanist integrates seamlessly with Compose-based projects and offers a more concise API.
:balloon: Modernized and sophisticated tooltips, fully customizable with an arrow and animations for Android.
Pros of Balloon
- Focused specifically on creating tooltips and popups
- Simpler API for basic use cases
- Includes built-in animations and customization options
Cons of Balloon
- Limited to tooltip/popup functionality
- Less integration with other Jetpack Compose components
- Smaller community and fewer contributors
Code Comparison
Balloon:
Balloon.Builder(context)
.setArrowSize(10)
.setBackgroundColor(ContextCompat.getColor(context, R.color.colorPrimary))
.setLifecycleOwner(lifecycleOwner)
.build()
.showAlignBottom(anchor)
Accompanist:
Popup(
alignment = Alignment.BottomCenter,
offset = IntOffset(0, -10),
properties = PopupProperties(focusable = true)
) {
Surface(
color = MaterialTheme.colors.primary,
shape = MaterialTheme.shapes.medium
) {
// Popup content
}
}
Summary
Balloon is a specialized library for creating tooltips and popups, offering a simpler API and built-in customization options. Accompanist, on the other hand, is a broader collection of utilities for Jetpack Compose, providing more flexibility and integration with other Compose components. While Balloon may be easier to use for basic tooltip scenarios, Accompanist offers more extensive functionality for complex UI requirements in Compose applications.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Accompanist is a group of libraries that aim to supplement Jetpack Compose with features that are commonly required by developers but not yet available.
Accompanist is a labs like environment for new Compose APIs. We use it to help fill known gaps in the Compose toolkit, experiment with new APIs and to gather insight into the development experience of developing a Compose library. The goal of these libraries is to upstream them into the official toolkit, at which point they will be deprecated and removed from Accompanist.
For more details like, why does this library exist? Why is it not part of AndroidX? Will you be releasing more libraries? Check out our Accompanist FAQ.
Compose versions
Each release outlines what version of the Compose UI libraries it depends on. We are currently releasing multiple versions of Accompanist for the different versions of Compose:
Compose 1.0 (1.0.x) | |
Compose 1.1 (1.1.x) | |
Compose UI 1.2 (1.2.x) | |
Compose UI 1.3 (1.3.x) | |
Compose UI 1.4 (1.4.x) | |
Compose UI 1.5 (1.5.x) | |
Compose UI 1.6 (1.6.x) | |
Compose UI 1.7 & 1.8 (1.7.x) |
For stable versions of Compose, we use the latest stable version of the Compose compiler. For non-stable versions (alpha, beta, etc), we use the latest compiler at the time of release.
:warning: Ensure you are using the Accompanist version that matches with your Compose UI version: If you upgrade Accompanist, it will upgrade your Compose libraries version via transitive dependencies.
Libraries
Γ°ΒΒΒ« Permissions
A library that provides Android runtime permissions support for Jetpack Compose.
Γ°ΒΒΒΓ―ΒΈΒ Drawable Painter
A library which provides a way to use Android Drawables as Jetpack Compose Painters.
Γ°ΒΒΒ Adaptive
A library providing a collection of utilities for adaptive layouts.
Γ’Β¬ΒΓ―ΒΈΒ Swipe to Refresh (Deprecated)
See our Migration Guide for migrating to PullRefresh in Compose Material.
Γ°ΒΒΒ¨ AppCompat Theme Adapter (Deprecated)
See our Migration Guide for migrating to the new artifact in Accompanist.
Γ°ΒΒΒ Pager (Deprecated)
See our Migration Guide for migrating to Pager in Compose.
Γ°ΒΒΒ Flow Layouts (Deprecated)
See our Migration Guide for migrating to FlowLayout in Compose.
Γ°ΒΒ§ΒΓ’ΒΒ¨Navigation-Animation (Deprecated)
See our Migration Guide for migrating to using built in support for animations in Jetpack Navigation Compose.
Γ°ΒΒ§ΒΓ°ΒΒ¨ï¸ Navigation-Material (Deprecated)
See our Migration Guide for migrating to using built in material-navigation support.
Γ’ΒΒ³ Placeholder (Deprecated)
A library that provides easy-to-use modifiers for displaying a placeholder UI while content is loading.
Γ°ΒΒΒ« System UI Controller (Deprecated)
We recommend migrating to edge to edge. See our Migration Guide for more details.
Γ°ΒΒΒ¨ AppCompat Theme Adapter (Deprecated)
A library that enables the reuse of AppCompat XML themes, for theming in Jetpack Compose.
Γ°ΒΒΒ¨ Material Theme Adapter (Deprecated)
A library that enables the reuse of MDC-Android Material 2 XML themes, for theming in Jetpack Compose.
Γ°ΒΒΒ¨ Material 3 Theme Adapter (Deprecated)
A library that enables the reuse of MDC-Android Material 3 XML themes, for theming in Jetpack Compose.
Γ°ΒΒΒ Web (Deprecated)
A wrapper around WebView for basic WebView support in Jetpack Compose.
Γ°ΒΒΒ Test Harness (Deprecated)
Utilities for testing Compose layouts.
Γ°ΒΒΒ Insets (Deprecated & Removed)
See our Migration Guide for migrating to Insets in Compose.
Future?
Any of the features available in this group of libraries may become obsolete in the future, at which point they will (probably) become deprecated.
We will aim to provide a migration path (where possible), to whatever supersedes the functionality.
Snapshots
Snapshots of the current development version of Accompanist are available, which track the latest commit. See here for more information.
Why the name?
The library is all about adding some utilities around Compose. Music composing is done by a composer, and since this library is about supporting composition, the supporting role of an accompanist felt like a good name.
Contributions
Please contribute! We will gladly review any pull requests. Make sure to read the Contributing page first though.
License
Copyright 2020 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Top Related Projects
Modular and customizable Material Design UI components for Android
Render After Effects animations natively on Android and iOS, Web, and React Native
A curated list of awesome Android UI/UX libraries
π A beautiful, fluid, and extensible dialogs API for Kotlin & Android.
ζι« Android UI εΌεζηη UI εΊ
:balloon: Modernized and sophisticated tooltips, fully customizable with an arrow and animations for Android.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot