Category: Jetpack Compose

  • Drawing Text on a Compose Canvas with drawText

    Text is drawn on a canvas using DrawScope’s drawText() function and a TextMeasurer instance. The role of TextMeasurer is to calculate the size of the text drawing based on factors such as font family and size. We can obtain a TextMeasurer instance by making a call to the rememberTextMeasurer() function as follows: Having obtained a…

  • Detecting Swipe Gestures in Jetpack Compose

    The preceding chapter demonstrated how to detect some common types of gestures, including dragging, tapping, pinching, and scrolling. Detecting swipe gestures is a little more complicated than other gesture types, which is why we are dedicating an entire chapter to the subject. This chapter will explain exactly what swipe gestures are and demonstrate how they…

  • Creating, Testing, and Uploading an Android App Bundle

    Once the development work on an Android application is complete and it has been tested on a wide range of Android devices, the next step is to prepare the application for submission to Google Play. Before submission can take place, however, the application must be packaged for release and signed with a private key. This…

  • A Material Design 3 Theming Tutorial

    This chapter will demonstrate how to create a new theme using the Material Theme Builder tool, integrate it into an Android Studio project, and test dynamic theme colors. Creating the ThemeDemo project Launch Android Studio and create a new Empty Activity project named ThemeDemo, specifying com.example. themedemo as the package name and selecting a minimum…

  • Custom Jetpack Compose Themes

    The appearance of Android apps is intended to conform to a set of guidelines defined by Material Design. Google developed Material Design to provide a level of design consistency between different apps while also allowing app developers to include their own branding in terms of color, typography, and shape choices (a concept referred to Material…

  • A Jetpack Compose In-App Purchasing Tutorial

    In the previous chapter, we explored how to integrate in-app purchasing into an Android project and also looked at some code samples that can be used when working on your own projects. This chapter will put this theory into practice by creating an example project demonstrating how to add a consumable in-app product to an…

  • A Jetpack Compose SharedFlow Tutorial

    The previous chapter introduced Kotlin flows and explored how these can be used to return multiple sequential values from within coroutine-based asynchronous code. In this tutorial, we will look at a more detailed flow implementation, this time using SharedFlow. The tutorial will also demonstrate how to ensure that flow collection responds correctly to an app…

  • Kotlin Flow with Jetpack Compose

    The earlier chapter, titled Coroutines and LaunchedEffects in Jetpack Compose, taught us about Kotlin Coroutines and explained how they can be used to perform multiple tasks concurrently without blocking the main thread. A shortcoming of suspend functions is that they are typically only useful for performing tasks that either do not return a result or…

  • Jetpack Compose Gesture Detection

    The term “gesture” is used to define a contiguous sequence of interactions between the touch screen and the user. A typical gesture begins at the point that the screen is first touched and ends when the last finger or pointing device leaves the display surface. When correctly harnessed, gestures can be implemented as a form…

  • A Jetpack Compose Navigation Bar Tutorial

    Following on from the overview provided previously in the chapter entitled Screen Navigation in Jetpack Compose this chapter will create a project that integrates navigation into an activity using the Compose BottomNavigation component. The project will also provide a brief introduction to the Scaffold component and demonstrate how it can be used to create a…