r/JetpackComposeDev • • Sep 02 '25

Tips & Tricks How to use Lazy Grids & Staggered Grids in Jetpack Compose

Thumbnail
gallery
16 Upvotes

Lazy grids help display items in a scrollable grid layout.

TipsExample
Use Vertical Grids for natural scrolling layoutsPhoto gallery app
Use Horizontal Grids for carousel-style listsMovie streaming app
Choose Fixed Columns/Rows for consistent designShopping product grid
Prefer Adaptive Size for responsive layoutsNews article cards
Apply Item Span to highlight important itemsSection header like “Fruits”
Use Staggered Grids for uneven item sizesPinterest-style photo feed
Add Spacing & Padding for better readabilitySocial media explore page

r/JetpackComposeDev • • Aug 30 '25

KMP How to Migrate existing apps to Room KMP

Post image
16 Upvotes

Learn how to share the database of your app with Room and Kotlin Multiplatform. This way you can share your most critical business logic with the iOS app preventing unwanted bugs or missing features while preserving the same..

https://developer.android.com/codelabs/kmp-migrate-room


r/JetpackComposeDev • • Aug 15 '25

Tips & Tricks How to keep your android apps secure | Pro tips for securing your android apps

Thumbnail
gallery
16 Upvotes

This guide covers security practices every senior developer should know:

  • Android Keystore & biometric encryption

  • SSL pinning & reverse engineering protection

  • Encrypted storage & secure API communication

  • Tapjacking prevention, root detection, Play Integrity API

  • Common security pitfalls even experienced developers make

Important: No app can ever be 100% secure. The goal is to mitigate risks and raise the security level as much as possible.

Discussion: What security measures or strategies do you implement in your Android apps?

Which practical actions have you found most effective in reducing risks without overcomplicating development?

Share articles, tips, or videos to help improve Android app security


r/JetpackComposeDev • • Aug 14 '25

Tips & Tricks Hilt & Dagger DI Cheat Sheet - 2025 Android Interview Prep

Thumbnail
gallery
16 Upvotes

Why Hilt for Jetpack Compose?

  • Inject ViewModels easily with @ HiltViewModel

  • Manage dependencies with scopes like@ Singleton

  • Keep Composables clean and testable

  • Works with Navigation Compose

  • Less boilerplate, more focus on UI

Interview hot topics:

  • What is DI & why use it?

  • Hilt vs Koin vs Dagger

  • Injecting ViewModels in Compose

  • Scopes → @ Singleton, @ ActivityScoped

  • Constructor vs field injection

  • Testing with fake/mock dependencies

Quick framework snapshot:

  • Hilt → Google standard, @ HiltViewModel

  • Koin → Kotlin DSL, viewModel{}

  • Dagger → Powerful but complex


r/JetpackComposeDev • • Oct 20 '25

Discussion The Hidden Class That Makes Jetpack Compose Feel So Fast

Post image
15 Upvotes

Most Android developers know about LazyColumn or remember in Compose - but very few know about a tiny internal class that quietly powers its performance: PrioritySet.

It’s not part of the public API, yet it plays a key role in how Compose schedules and manages recompositions efficiently.

What it does:

  • Stores integer priorities for operations

  • Tracks the maximum efficiently using a heap

  • Avoids duplicates for better performance

  • Defers cleanup until removal to stay fast under heavy workloads

This smart design lets Compose handle UI updates predictably without wasting time - a great example of practical performance engineering.

Even if you never use it directly, understanding PrioritySet offers insight into how Compose achieves its smooth performance - and how you can apply similar principles when designing custom schedulers or layout systems.

Discussion time
Have you ever explored Jetpack Compose internals?
Do you think reading framework code helps us become better Android engineers - or is it overkill?

Credit : Akshay Nandwana


r/JetpackComposeDev • • Oct 02 '25

Tool Struggling to reach 12 testers?

Post image
15 Upvotes

12 Testers - 14 Days Free Solution

  • You get 12 real testers for 14 days - completely free.

  • To unlock this, you simply test other apps (mutual exchange).

  • While testing others’ apps, you’ll automatically earn testers for your own app.

  • This way, your app gets tested on 12 different devices without any cost.


r/JetpackComposeDev • • Sep 23 '25

KMP Compose Multiplatform 1.9.0 Released: Compose Multiplatform for Web Goes Beta

Thumbnail
gallery
15 Upvotes

Compose Multiplatform for web, powered by Wasm, is now in Beta! This major milestone shows that Compose Multiplatform for web is no longer just experimental, but ready for real-world use by early adopters.

Compose Multiplatform 1.9.0

AreaWhat’s New
WebNow in Beta (Wasm powered). Material 3, adaptive layouts, dark mode, browser navigation, accessibility, HTML embedding.
EcosystemLibraries for networking, DI, coroutines, serialization already web-ready. Growing catalog at klibs.io.
ToolsIntelliJ IDEA & Android Studio with Kotlin Multiplatform plugin. Project wizard for web, run/debug in browser, DevTools support.
DemosKotlin Playground, KotlinConf app, Rijksmuseum demo, Jetsnack Wasm demo, Material 3 Gallery, Storytale gallery.
iOSFrame rate control (Modifier.preferredFrameRate), IME options (PlatformImeOptions).
DesktopNew SwingFrame() & SwingDialog() to configure windows before display.
All PlatformsMore powerful @ Preview parameters, customizable shadows (dropShadow / innerShadow).

Learn more:

What’s new in Compose Multiplatform 1.9.0

https://www.jetbrains.com/help/kotlin-multiplatform-dev/whats-new-compose-190.html
https://blog.jetbrains.com/kotlin/2025/09/compose-multiplatform-1-9-0-compose-for-web-beta/


r/JetpackComposeDev • • Aug 30 '25

Tutorial How to create Sticky Headers in Jetpack Compose

Thumbnail
gallery
15 Upvotes

Sticky headers are useful when you want certain items (like section titles) to stay visible at the top while scrolling through a list.

Jetpack Compose provides the experimental stickyHeader() API in LazyColumn.

Single Sticky Header Example

@OptIn(ExperimentalFoundationApi::class)
@Composable
fun ListWithHeader(items: List<Item>) {
    LazyColumn {
        stickyHeader {
            Header() // This header will stick at the top
        }

        items(items) { item ->
            ItemRow(item)
        }
    }
}

Multiple Sticky Headers Example (Grouped List)

val grouped = contacts.groupBy { it.firstName[0] }

@OptIn(ExperimentalFoundationApi::class)
@Composable
fun ContactsList(grouped: Map<Char, List<Contact>>) {
    LazyColumn {
        grouped.forEach { (initial, contactsForInitial) ->

            stickyHeader { 
                CharacterHeader(initial) 
            }

            items(contactsForInitial) { contact ->
                ContactListItem(contact)
            }
        }
    }
}

Why Use Sticky Headers?

  • Great for categorized lists (contacts, messages, tasks)

  • Improves readability by keeping section headers visible

  • Works seamlessly with LazyColumn


r/JetpackComposeDev • • Jul 30 '25

Tips & Tricks Choosing the Right State Tool in Jetpack Compose

Post image
15 Upvotes

Jetpack Compose State Tools - When to Use What

FeatureUse It When…Example Use Case
rememberSaveableYou need to persist state across screen rotations or process death, especially for user input or selection.Form inputs, tab selection, scroll state, selected filters, navigation state
mutableStateOfYou need a value that triggers recomposition; always wrap with remember or use inside ViewModel.Counter value, toggle switch state, form field input, checkbox status
rememberYou want to cache temporary state during composition that doesn't need to survive configuration changes.Text field preview, random color, temporary animation state, computed layout size
derivedStateOfYou need to compute state from other state efficiently, avoiding recomposition unless dependencies change.Validation: isValid = text.length > 3, button enable/disable, formatted display text
State HoistingYou are designing reusable/stateless composables and want the parent to control the state. Promotes modularity and unidirectional flow.Custom button, reusable form field, dialog state management, list item selection

Code Example:

below are simple code examples for each state tool

rememberSaveable Example

@Composable
fun SaveableInput() {
    // Persist text across rotations and process death
    var text by rememberSaveable { mutableStateOf("") }
    // TextField retains input after config change
    TextField(value = text, onValueChange = { text = it }, label = { Text("Name") })
}

mutableStateOf Example

@Composable
fun Counter() {
    // State triggers UI update when changed
    var count by remember { mutableStateOf(0) }
    // Button increments count, causing recomposition
    Button(onClick = { count++ }) {
        Text("Count: $count")
    }
}

remember Example

@Composable
fun RandomColor() {
    // Cache random color for composition lifetime
    val color = remember { Color(Random.nextInt(256), Random.nextInt(256), Random.nextInt(256)) }
    // Box uses cached color, reset only on recompose
    Box(Modifier.size(100.dp).background(color))
}

derivedStateOf Example

@Composable
fun FormValidation() {
    // Input state for text
    var text by remember { mutableStateOf("") }
    // Derived state updates only when text changes
    val isValid by derivedStateOf { text.length > 3 }
    // Button enabled based on validation
    Button(onClick = {}, enabled = isValid) {
        Text("Submit")
    }
}

State Hoisting Example

@Composable
fun Parent() {
    // Parent manages state
    var text by remember { mutableStateOf("") }
    // Pass state and event to stateless child
    TextInputField(text = text, onTextChange = { text = it })
}

@Composable
fun TextInputField(text: String, onTextChange: (String) -> Unit) {
    // Stateless composable, reusable across contexts
    TextField(value = text, onValueChange = onTextChange, label = { Text("Input") })
}

r/JetpackComposeDev • • Jul 29 '25

KMP Native iOS Look in Jetpack Compose Multiplatform? | iOS-Style Widgets for KMP

15 Upvotes

Just came across this cool Kotlin Multiplatform project that brings iOS style (Cupertino) widgets to Compose Multiplatform.

It follows native iOS design and even supports adaptive themes!

If you are building for iOS with Jetpack Compose Multiplatform, give this a try:
👉 Compose Cupertino

Looks pretty useful for achieving a native feel on iOS!

Supported Platforms:

• Android • iOS • macOS • Web • JVM


r/JetpackComposeDev • • Nov 29 '25

KMP Cross-Platform To-Do App - Built with Kotlin Multiplatform

14 Upvotes

Just came across this clean and well-structured open-source To-Do App built using Kotlin Multiplatform (KMP) - a perfect example of how modern Android + iOS development can be unified with a shared codebase.

GitHub: https://github.com/Kamal02D/DoIt

Highlights:
✔️ Built with Kotlin Multiplatform (KMP)
✔️ Beautiful Jetpack Compose UI
✔️ Room + SQLite for smooth and reliable data storage
✔️ Koin for clean dependency injection
✔️ Simple, responsive, and user-friendly design


r/JetpackComposeDev • • Oct 29 '25

UI Showcase Smooth Animations in Jetpack Compose Made Easy with animateDpAsState

14 Upvotes

Thanks to Jetpack Compose, animation logic blends right into your UI declaration.
Just a few lines of code, and you can create smooth, responsive transitions that make your app feel premium and intentional.

Experimenting with animateDpAsState one of Compose’s neat little APIs that makes UI transitions incredibly fluid.

The goal was simple:
Animate a button’s vertical offset based on the bottom sheet’s position.

Core Snippet

val targetY by animateDpAsState(
    targetValue = when (sheetState.currentValue) {
        SheetValue.Hidden -> 0.dp
        else -> {
            val currentOffset = with(density) {
                try { sheetState.requireOffset().toDp() }
                catch (_: Exception) { 0.dp }
            }

            (usableHeight - currentOffset)
                .coerceAtLeast(0.dp)
                .coerceAtMost(maxLift)
        }
    },
    label = "gps_button_animation"
)

Box(
    modifier = Modifier
        .offset(y = -targetY) // Negative offset moves the button up
) {
    // Button content here
}

Credit : Bawender


r/JetpackComposeDev • • Aug 25 '25

Tips & Tricks Jetpack Compose State Management: Solve Issues with MVVM + UDF

Thumbnail
gallery
14 Upvotes

Common Problems in Jetpack Compose Apps (State Management)

  • State lost on rotation

  • Logic mixed with UI

  • Hard to test

  • Multiple sources of truth

MVVM + Unidirectional Data Flow (UDF) to the Rescue

  • Single source of truth

  • Events go up, state flows down

  • Survives configuration changes

  • Easier to test

Tip:

Keep business logic inside your ViewModel, expose immutable StateFlow, and keep Composables stateless for a clean architecture.

Credit: Thanks to Tashaf Mukhtar for sharing these insights.


r/JetpackComposeDev • • Aug 21 '25

Tutorial How to Use Flow Layouts in Jetpack Compose for Flexible UIs

14 Upvotes

What are Flow Layouts?

Flow layouts arrange items flexibly, adapting to screen size.
If items don’t fit in one line, they automatically wrap to the next.

Why Use Them?

  • Solve problems with fixed layouts that break on small/large screens.

  • Ensure UI looks good across different devices and orientations.

How Elements are Arranged

  • Row → horizontal arrangement

  • Column → vertical arrangement

  • Flow Layouts → adaptive arrangement (items wrap automatically)

Adaptability

  • Flow layouts adjust based on available space.

  • Makes UIs responsive and user-friendly.


r/JetpackComposeDev • • Aug 19 '25

Made Twitter Like application using jetpack compose and firebase

14 Upvotes

Hey everyone, I was learning Jetpack compose, and Firebase. And I made this app which is more or less like twitter like. I have used Firebase Auth, Firestore, and Realtime database here. Wanted to use firebase storage, but it required a billing account, but I didn't wanna do it. In the app I made basic CRUD related operations to posts, and comments. Also made a chat feature, using realtime database for checking the online status of the user.

One thing which I found very odd about firebase was that it didn't have inbuilt search and querying feature and they recommend third party APIs.

Overall it was a good experience building it. this is the github link: https://github.com/saswat10/JetNetwork

Would be happy to get some suggestions on what I can do more to improve.


r/JetpackComposeDev • • Aug 12 '25

Tips & Tricks How to Use Lint with Jetpack Compose - Pro Tips & Tricks for Cleaner Code

Thumbnail
gallery
14 Upvotes

Android Lint is a static analysis tool that inspects your code for potential bugs, performance issues, and bad practices.
When working with Jetpack Compose, Lint can catch Compose-specific issues such as

  • Unnecessary recompositions

  • Inefficient modifier usage

  • Unstable parameters in composables

  • Accessibility problems

  • Use of deprecated Compose APIs

Tip: If you cannot upgrade AGP, set the Lint version manually in gradle.properties:

android.experimental.lint.version = 8.8.2

How to Run Lint

Command / ActionPurpose
./gradlew lintRuns lint on all modules
./gradlew lintDebugRuns lint for the Debug build only
./gradlew lintReleaseRuns lint for the Release build
./gradlew lintVitalReleaseRuns only critical checks for release builds
./gradlew lint --continueRuns lint without stopping at first failure
./gradlew lint --offlineRuns lint using cached dependencies (faster in CI)
./gradlew :moduleName:lintRuns lint for a specific module
Android Studio → Analyze → Inspect CodeRuns lint interactively in the IDE
Android Studio → Build → Analyze APKChecks lint on an APK output
Open app/build/reports/lint-results.htmlView full lint report in a browser
Use lintOptions in build.gradleCustomize which checks to enable/disable

Best Practices

  • Run lint before every release

  • Treat warnings as errors in CI for critical checks

  • Fix accessibility warnings early to avoid legal issues

  • Use lintVitalRelease in release pipelines to keep APKs clean


r/JetpackComposeDev • • Jul 24 '25

Tips & Tricks Jetpack Compose: Arrangement Cheat Sheet

Thumbnail
gallery
14 Upvotes

Arrangement controls how children are placed along the main axis in layouts like Row and Column.

Arrangement Types

TypeUsed In
Arrangement.HorizontalRow
Arrangement.VerticalColumn
Arrangement.HorizontalOrVerticalBoth

Predefined Arrangements

NameDescription
StartAlign to start (left in LTR) — Row only
EndAlign to end (right in LTR) — Row only
TopAlign to top — Column only
BottomAlign to bottom — Column only
CenterCenter items in main axis
SpaceBetweenEqual space between items only
SpaceAroundEqual space around items (half at ends)
SpaceEvenlyEqual space between and around all items

Functions

aligned(...)

Align a group of children together within the layout.

Row(
    horizontalArrangement = Arrangement.aligned(Alignment.CenterHorizontally)
)

Column(
    verticalArrangement = Arrangement.aligned(Alignment.Top)
)

spacedBy(...)

Add fixed space between children.

Row(
    horizontalArrangement = Arrangement.spacedBy(16.dp)
)

Column(
    verticalArrangement = Arrangement.spacedBy(8.dp)
)

You can also specify alignment within spacedBy:

Row(
    horizontalArrangement = Arrangement.spacedBy(12.dp, Alignment.CenterHorizontally)
)

Column(
    verticalArrangement = Arrangement.spacedBy(20.dp, Alignment.Bottom)
)

Visual Examples (LTR Layout)

ArrangementRow Layout (123 = items)
Start123####
End####123
Center##123##
SpaceBetween1##2##3
SpaceAround#1##2##3#
SpaceEvenly#1#2#3#

Usage in Code

For Row:

Row(
    horizontalArrangement = Arrangement.SpaceEvenly
)

For Column:

Column(
    verticalArrangement = Arrangement.Bottom
)

Notes:

  • Use Arrangement to control child placement in Row or Column

  • Combine with Alignment and Modifier for full layout control

  • Most common: Center, Start, End, SpaceEvenly, SpaceBetween

Tip: Pair Arrangement with Alignment for perfect centering or balance


r/JetpackComposeDev • • Jul 22 '25

Tips & Tricks Jetpack Compose Animation Tips & Cheat Sheet (2025 Edition)

Post image
14 Upvotes

If you are working with Jetpack Compose animations and want a quick, visual reference for the most commonly used APIs - this cheat sheet is for you. Save it, share it, and speed up your development with smooth, beautiful animations.

Official Cheat Sheet (PDF) : Download the 2025 Jetpack Compose Animation Cheat Sheet (PDF)

Quick Summary Table

CategoryAPI/MethodPurpose
Basic AnimationsAnimatedVisibilityShow/hide elements with enter/exit animations
animate*AsState()Animate simple values like color, size, offset
updateTransition()Animate multiple states simultaneously
rememberInfiniteTransition()Loop animations infinitely (e.g., shimmer)
Animatable + LaunchedEffectCustom/manual animations with precise control
Layout & ItemsanimateContentSize()Animate size changes when layout updates
animateItemPlacement()Animate item position changes in LazyColumn/Row
AnimatedContent()Animate between different composables
Crossfade()Fade transition between composables
animatedVectorResource()Animate vector drawables defined in XML
Custom Controlstween(), spring(), snap()Control duration, stiffness, damping, etc.
RepeatMode.ReverseReverse animation in loop (ping-pong effect)
EasingAdjust speed curve of animation

Learn More

Share Your Work!

Have you built something cool with animations in Compose?
Drop your GitHub repo, blog post, or demo link in the comments to help others learn!


r/JetpackComposeDev • • Dec 11 '25

Please help

Post image
13 Upvotes

Hi guys, I have been trying to learn Jetpack Compose from YouTube tutorials (the tutorial I am using is from about a year ago), and I am struggling with the icons. Please help, I tried to find a way to fix it, but so far, nothing works.


r/JetpackComposeDev • • Nov 24 '25

Tutorial Sharpen your Jetpack Compose skills with these codelabs! →

Post image
13 Upvotes

Earn a badge for your Google Developer Profile and learn how Compose simplifies and accelerates UI development on Android with less code, powerful tools, and intuitive Kotlin APIs.

https://developer.android.com/courses/jetpack-compose/course


r/JetpackComposeDev • • Nov 05 '25

Tips & Tricks Flow : zip vs combine

Thumbnail
gallery
13 Upvotes

The difference between zip and combine becomes most apparent in fast-slow scenarios, which is crucial for understanding how they handle backpressure and data loss.

🐢 Fast-Slow Scenario with zip
When one stream is faster than the other, zip inherently provides a mechanism for slowing down the fast stream.

👉 Behavior: The zip operator will always wait for a new value from the slowest stream before it can emit a pair.
👉 Backpressure: The fast stream's emissions are essentially buffered (held) until the slow stream produces a corresponding partner. This effectively applies backpressure to the fast stream, preventing it from overwhelming the operator or the consumer.
👉 Data Pairing: Every single emission from the slow stream will be paired with the next available emission from the fast stream, ensuring a strict one-to-one mapping.

🏃 Fast-Slow Scenario with combine

When one stream is faster, combine can result in skipped values from the fast stream because it only cares about the latest value from the slow stream.

👉 Behavior: The combine operator emits a new value any time either stream emits. It pairs the new value with the most recently emitted value from the other stream.
👉 Data Loss/Skipping: If the fast stream emits multiple values before the slow stream emits its next one, the intermediate values from the fast stream are skipped in the final output, as they are overwritten by the latest value.
👉 Backpressure: It doesn't apply strict backpressure to the fast stream in the same way zip does, as it only uses the latest available value.

🚀 Key takeaway
:: zip is synchronous in its pairing, ensuring no data is lost from the slow stream, and buffering is used for the fast stream.
:: combine is asynchronous in its update, prioritizing up-to-date state. It results in data skipping from the faster stream if the slower stream hasn't updated.

Credit : Arya Bhavate


r/JetpackComposeDev • • Aug 19 '25

KMP How to make a Custom Snackbar in Jetpack Compose Multiplatform | KMP

13 Upvotes

This article shows how to create a custom Gradient Snackbar in Jetpack Compose for Kotlin Multiplatform (KMP). It’s useful for giving user feedback, like confirming actions or saving settings, across different platforms.

Read more: Gradient Snackbar in Jetpack Compose


r/JetpackComposeDev • • Aug 07 '25

KMP A Better Way to Discover Kotlin Multiplatform Libraries | Kotlin Multiplatform Plugin Compatibility Tips [klibs.io]

Thumbnail
gallery
13 Upvotes

I came across one of the best sites for Kotlin Multiplatform devs - klibs.io!

Kotlin Multiplatform (KMP) is growing fast, with 35% more libraries added in 2024. But with more libraries, it is harder to find the right one for your project.

That is why klibs.io was created, a website to help you:

  • 🔍 Find KMP libraries by purpose and supported platforms (JVM, Android, iOS, Web, etc.)

  • ⚡ Save time by getting AI-generated info about libraries

  • 📈 Help library authors get more visibility


r/JetpackComposeDev • • Jul 27 '25

Tutorial Jetpack Compose Box Alignment - Beginner-Friendly Demo

Thumbnail
gallery
13 Upvotes

Learn how to align content in 9 different positions using Box in Jetpack Compose.

This is a simple, visual guide for beginners exploring layout alignment.

@Composable
fun BoxDemo() {
    Box(
        modifier = Modifier
            .background(color = Color.LightGray)
            .fillMaxSize()
    ) {
        Text(
            modifier = Modifier
                .background(Color.White)
                .padding(10.dp)
                .align(Alignment.TopStart),
            text = "TopStart"
        )
        Text(
            modifier = Modifier
                .background(Color.White)
                .padding(10.dp)
                .align(Alignment.TopCenter),
            text = "TopCenter"
        )
        Text(
            modifier = Modifier
                .background(Color.White)
                .padding(10.dp)
                .align(Alignment.TopEnd),
            text = "TopEnd"
        )
        Text(
            modifier = Modifier
                .background(Color.White)
                .padding(10.dp)
                .align(Alignment.CenterStart),
            text = "CenterStart"
        )
        Text(
            modifier = Modifier
                .background(Color.White)
                .padding(10.dp)
                .align(Alignment.Center),
            text = "Center"
        )
        Text(
            modifier = Modifier
                .background(Color.White)
                .padding(10.dp)
                .align(Alignment.CenterEnd),
            text = "CenterEnd"
        )
        Text(
            modifier = Modifier
                .background(Color.White)
                .padding(10.dp)
                .align(Alignment.BottomStart),
            text = "BottomStart"
        )
        Text(
            modifier = Modifier
                .background(Color.White)
                .padding(10.dp)
                .align(Alignment.BottomCenter),
            text = "BottomCenter"
        )
        Text(
            modifier = Modifier
                .background(Color.White)
                .padding(10.dp)
                .align(Alignment.BottomEnd),
            text = "BottomEnd"
        )
    }
}

r/JetpackComposeDev • • Oct 27 '25

Question How to make the same animation of the predictive "back" gesture?

12 Upvotes

I'm making my app on Jetpack Compose using Navigation 3. How can I achieve the same gesture as in Android settings, the Reddit app, or Gmail? An animation that tracks not only progress, but also touchpoints on the X and Y...