Google is committed to advancing racial equity for Black communities. See how.

Compose UI

Fundamental components of compose UI needed to interact with the device, including layout, drawing, and input.
Latest Update Current Stable Release Next Release Candidate Beta Release Alpha Release
September 16, 2020 - - - 1.0.0-alpha03

Structure

Compose is combination of 7 Maven Group Ids within androidx. Each Group contains a targeted subset of functionality, each with it's own set of release notes.

This table explains the groups and links to each set of release notes.

GroupDescription
composeDefine your UI programmatically with composable functions that describe its shape and data dependencies.
compose.animationBuild animations in their Jetpack Compose applications to enrich the user experience.
compose.foundationWrite Jetpack Compose applications with ready to use building blocks and extend foundation to build your own design system pieces.
compose.materialBuild Jetpack Compose UIs with ready to use Material Design Components. This is the higher level entry point of Compose, designed to provide components that match those described at www.material.io.
compose.runtimeFundamental building blocks of Compose's programming model and state management, and core runtime for the Compose Compiler Plugin to target.
compose.uiFundamental components of compose UI needed to interact with the device, including layout, drawing, and input.
uiWorks with the Jetpack Compose library.

Declaring dependencies

To add a dependency on Compose, you must add the Google Maven repository to your project. Read Google's Maven repository for more information.

Add the dependencies for the artifacts you need in the build.gradle file for your app or module:

dependencies {
    implementation "androidx.compose.ui:ui:1.0.0-alpha03"
}

android {
    buildFeatures {
        compose true
    }

    composeOptions {
        kotlinCompilerVersion "1.4.0"
        kotlinCompilerExtensionVersion "1.0.0-alpha03"
    }
}

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
    kotlinOptions {
        jvmTarget = "1.8"
        freeCompilerArgs += ["-Xallow-jvm-ir-dependencies", "-Xskip-prerelease-check"]
    }
}

For more information about dependencies, see Add build dependencies.

Feedback

Your feedback helps make Jetpack better. Let us know if you discover new issues or have ideas for improving this library. Please take a look at the existing issues in this library before you create a new one. You can add your vote to an existing issue by clicking the star button.

Create a new issue

See the Issue Tracker documentation for more information.

Version 1.0.0

Version 1.0.0-alpha03

September 16, 2020

androidx.compose.ui:ui-*:1.0.0-alpha03 is released. Version 1.0.0-alpha03 contains these commits.

API Changes

  • Remove scroll forward/backward semantics actions. Added steps in AccessibilityRangeInfo. (Ia47b0)
  • Removed onInvalidate() from Owner -- OwnedLayer handles invalidation. (Ica72b, b/162061312)
  • Removed operator methods on Size API that consume Offset parameters. The result of these operations is unclear and the type of result is unexpected for these. Ex. should size - offset return an offset or a size result with the difference?

    Also removed deprecated methods on Size class. (Iec902, b/166514214)

Bug Fixes

  • Fix for items of LazyColumn being incorrectly drawn sometimes, this was also causing crashes in some conditions. (Ibcf17, b/163066980, b/165921895)
  • DpConstraints and APIs using it were deprecated. (I90cdb, b/167389835)
  • Moved createAndroidComposeRule and AndroidInputDispatcher from androidx.ui.test.android to androidx.ui.test (Idef08, b/164060572)
  • Usages of gravity were consistently renamed to align or alignment in layout APIs. (I2421a, b/164077038)
  • Added onNode and other global methods on ComposeTestRule as the current global ones are going to be deprecated. (Ieae36)

Version 1.0.0-alpha02

September 2, 2020

androidx.compose.ui:ui-*:1.0.0-alpha02 is released. Version 1.0.0-alpha02 contains these commits.

API Changes

  • remove callback to notify Owner when layoutnode bounds change. (If654e, b/166106882)
  • Added support for filltype parameters on vector graphics paths to support cutouts of shapes according to evenOdd or NonZero path fill rules. (I43dd2)
  • Uptime and Velocity are now inline classes (I48f4a)
  • Duration is now an inline class (I565eb)
  • Add a callback to notify Owner when layoutnode bounds change. (Ic40b3)
  • Fixed issue where Rect function constructor with Offset and radius would create the Rect in the order of left, right, top, bottom instead of left, top, right, bottom.

    Removed deprecated companion methods on Rect in favor of function constructors.

    Added tests to verify methods in Rect.kt (I08460, b/165822356)

Bug Fixes

  • Added MutableRect, a rectangle that can be modified. (I71bd2, b/160140398)
  • Matrix4 was replaced with Matrix. All other parts of vectormath package have been removed. (Ibd665, b/160140398)
  • The calling convention for composable functions has changed. This is a binary breaking change. All libraries must be recompiled to work with this version of the compose compiler plugin.

    This change does not create a source level breaking change as the only APIs that have changed are compiler APIs that have an explicit opt in. (I7afd2, b/158123185)

  • Fixed crash that could occur when dispatch to a PointerInputFilter could cause the PointerInputFilter to be synchronously removed. (I58f25)

Version 1.0.0-alpha01

August 26, 2020

androidx.compose.ui:ui-*:1.0.0-alpha01 is released. Version 1.0.0-alpha01 contains these commits.

Version 0.1.0-dev

Version 0.1.0-dev17

August 19, 2020

androidx.compose.ui:ui-*:0.1.0-dev17 is released. Version 0.1.0-dev17 contains these commits.

API Changes

  • emitView was deprecated. Use AndroidView instead if possible for emitting Views inside Compose. Note that composing Views and ViewGroups directly will not be supported in the future unless these are leaves in the composition tree, case when this can be achieved using AndroidView. (I29b1e, b/163871221)
  • FocusState2 is deprecated and replaced by FocusState (Ia8b79, b/160822876, b/160923332)
  • The deprecated AndroidView overloads were removed. (I946b9, b/163802393)
  • Custom emits can now declare that one or more of its setters can be skipped and recomposed independently of the emit. (Ibbd13)
  • Changed Vector classes to no longer be data classes as the same object instance is used for composition.

    Added mutableStateOf flag for VectorPainter to conditionally re-draw if contents of the vector change.

    Refactored VectorComponent instance to be part of VectorPainter as it is re-used across compositions.

    Updated GroupComponent and PathComponent to have their name fields be mutable (Ieae45, b/151378808)

  • Removed onChildPositioned and OnChildPositionedModifier. Developers should use onPositioned and OnPositionedModifier on the child layout instead. (I4522e, b/162109766)

  • Offset has become an inline class (Iaec70)

  • Added a modifier param to SelectionContainer (I4aada, b/161487952)

  • Removed deprecated FocusModifier (I0b4ba, b/160922116, b/160821157, b/162441435, b/160822875, b/160921940)

  • Added mergePolicy lambda to SemanticsPropertyKey. This can be used to define a custom policy for mergeAllDescendants semantics merging. The default policy is to use the parent value if already present, otherwise the child value. (Iaf6c4, b/161979921)

  • Constraints is now an inline class (I88736)

  • Added FocusManager that moves common focus logic out of AndroidComposeView (I528ef, b/161487952, b/162206799)

  • Updated PointerEventPass names for Alpha release. (Ifda6f)

  • IntOffset is now an inline class (Iac0bf)

  • IntSize is now an inline class (I2bf42)

  • PlacementScope.placeAbsolute() was renamed to PlacementScope.place(), and the previous PlacementScope.place() was renamed to PlacementScope.placeRelative(). As a result, the PlacementScope.place() method will not automatically mirror the position in right-to-left contexts anymore. If this is desired, use PlacementScope.placeRelative() instead. (I873ac, b/162916675)

  • AlertDialog now uses FlowRow for buttons (I00ec1, b/161809319, b/143682374)

  • Made some test utilities non public because they are not where they belong. Will be made public in the future. (I32ab1)

  • Refactored organization of pointer input code. (Ie3f45)

  • Deprecated PxBounds in favor of Rect. Updated all usages of PxBounds with rect and added proper deprecate/replace with annotations to assist with the migration. (I37038, b/162627058)

  • Removed Deprecated KeyEvent2. Use KeyEvent instead. (Ied2d0, b/162097587)

  • KeyEvent has a unicode property that can be used to get the unicode character generated by the specified key and meta key state combination (If3afc)

  • Made the DelayUp custom event and related classes an opt in API as it is very likely going to be changed. (I56d6f)

  • Removed 2 PointerEventPasses that are no longer needed. (I3dd9d)

  • Add parameter color, shadow and TextDecoration to Paragraph.paint This function is useful to avoid unnecessary Paragraph recreation. (I81689)

Bug Fixes

  • Removed onFocusChanged callbacks from TextField. Use Modifier.focusObserver instead. (I51089, b/161297615)
  • Modifier.drawBorder has been deprecated. Use Modifier.border instead. Border data class has been replaced by BorderStroke (I4257d, b/158160576)
  • Removed deprecated FrameManager calls.

    Internal compose APIs have been changed to reduce the amount of overhead to track state objects such as mutableStateof() (I80ba6)

  • VerticalScroller and HorizontalScroller have been removed. Use ScrollableColumn/Row instead. Modifier.drawBackground has been removed. Use Modifier.background (I73b0d, b/163019183)

  • Crash when something which saves the state was used inside the for loop is fixed. Now having the same key in savedInstanceState() is allowed, api of UiSavedStateRegistry is now adjusted to this new requirement (I4ab76, b/160042650, b/156853976, b/159026663, b/154920561)

  • The state { ... } composable is now deprecated in favor of explicit calls to remember { mutableStateOf(...) } for clarity. This reduces the overall API surface and number of concepts for state management, and matches the by mutableStateOf() pattern for class property delegation. (Ia5727)

  • Renamed RRect to RoundRect to better fit compose naming patterns Created similar function constructors to RRect and deprecated RRect function constructors (I5d325)

Version 0.1.0-dev16

August 5, 2020

androidx.compose.ui:ui-*:0.1.0-dev16 is released. Version 0.1.0-dev16 contains these commits.

API Changes

  • OnChildPositioned has been deprecated. Use OnPositioned on the child instead. (I87f95, b/162109766)
  • setViewContent was deprecated. setContent should be used instead. (I7e497, b/160335130)
  • Added the AndroidViewBinding API for inflating and composing layout resources, based on ViewBinding. (I081c6)
  • KeyEvent2 is replaced by KeyEvent (I2d770, b/162097585)
  • Added support for Alt hardware key (I9036b)
  • FocusManager is Deprecated. Use Modifier.focus(), Modifier.focusObserver() and Modifier.focusRequester() instead. (I74ae4, b/162211322)
  • loadVectorResource supports trimPath attributes (I808fe)
  • Move dialog to ui (I47fa6)
  • Removed 2 PointerEventPasses that are no longer needed. (I33ca7)
  • Implemented PointerInteropModifier which provides the ability to receive MotionEvents and interact with Compose as if you are an implementation of an Android View. (Ieb08c)
  • Removed the deprecated tag modifier. Please use layoutId instead. (Idaa05, b/162023919)
  • The APIs for right-to-left support has been updated. LayoutDirectionAmbient has been added, which can be used to read and change the layout direction. Modifier.rtl and Modifier.ltr have been removed. (I080b3)
  • Support path trimming in vector graphics (Ie16c9, b/158188351)
  • Added Modifier.layout() that allows to create a custom layout modifier conveniently (I73b69, b/161355194)
  • Added a new AndroidView API and deprecated the existing ones. (I5bcfd)
  • Modifier.plus has been deprecated, use Modifier.then instead. 'Then' has a stronger signal of ordering, while also prohibits to type Modifier.padding().background() + anotherModifier, which breaks the chain and harder to read (Iedd58, b/161529964)
  • Add [Abstract]ComposeView View subclasses for hosting Compose content in a View hierarchy. (I46357)
  • Row and Column are now inline function significantly reducing the overhead of using them. (I75c10)
  • SubcomposeLayout is added. It is a low level primitive which allows to compose the children during the measuring if we want to use some values available only later during the measure for the subtree composition. For example WithConstraints is not implemented using SubcomposeLayout. (I25cc8)
  • Added SemanticsNode.positionInRoot to get the position of a SemanticsNode relative to the root of the Compose hierarchy (Icdf26, b/161336532)
  • MotionEvents passed all the way through from Android, into Compose, and back into Android. (I14be8, b/158034713)
  • Removed dropdownPopup. (I00430)
  • Fixed popup position on cut-out displays. (Idd7dd)
  • Add accessibility action to get TextLayoutResult (I9d6e6)
  • RemeasurementModifier added. it allows to synchronously remeasure the layout. In general you never need it as remeasure/relayout is happening automatically, but we use it inside LazyColumnItems during the scroll. (I5f331, b/160791058)
  • Remove getLineEllipsisOffset/getLineEllipsisCount. Use getLineVisibleEnd/getLineEnd/isLineEllipsized instead. (I85aa2)
  • Add some Marks/Annotations for best practice reason. (I66b20)
  • expose more line APIs in TextLayoutResult. (I79bd2)
  • Built-in vector converters to convert built-in units are now accessible via Foo.VectorConverter. e.g. Dp.VectorConverter, Color.VectorConverter, Float.VectorConverter, etc (I3e273)

Bug Fixes

  • Address broad API fixes (I077bc)
    1. Remove unused OffsetBase interface
    2. Align Offset and IntOffset classes to have a consistent API surface
    3. Rename IntOffset.Origin to IntOffset.Zero to be consistent with Offset API
    4. Moved nativeCanvas method off of Canvas interface to support consumers to create their own Canvas instances
    5. Created stub EmptyCanvas class to refactor DrawScope to be a non-null parameter instead of lateinit and ensure non-nullability of the field
    6. Renamed ClipOp enums to be Pascal Case
    7. Renamed FilterQuality enums to be Pascal Case
    8. Renamed StrokeJoin enums to be Pascal Case
    9. Renamed PointMode enums to be Pascal Case
    10. Renamed PaintingStyle enums to be Pascal Case
    11. Renamed PathFillType enums to be Pascal Case
    12. Renamed StrokeCap enums to be Pascal Case
    13. Updated DrawCache implementation to no longer use lateinit params
    14. Updated DrawScope to no longer use lazy delegation for fillPaint and strokePaint internal parameters
    15. Updated Image composable to avoid Box usage for less overhead
    16. Updated Outline class to have @Immutable annotations
    17. Updated PathNode to have @Immutable annotations for each path instruction
    18. Updated Vector subcomposition to remove redundant conditional checks for equality as compose already handles them
    19. Deprecated Rect companion constructor methods in favor of function constructors
    20. Updated Brush classes and function constructors with @Immutable and @Stable APIs
    21. Updated VertexMode enum to be PascalCase
    22. Updated DrawScope selectPaint method to conditionally overwrite stroke parameters on the paint if they have changed
    23. Updated Size to add destructuring API, rename UnspecifiedSize to Unspecified and removed unused methods
  • Updated compose BlendMode API consumption to properly map between Android framework BlendModes and PorterDuff modes depending on API level. Introduced BlendMode#isSupported API to act as a capability query to determine if the BlendMode is supported on the device before it is used. (I0ef42)
  • LazyItemScope was added for itemContent param of Lazy lists. It provides modifiers to fill the parent max size which solves the use case when the item should fill the viewport and the regular Modifier.fillMaxSize() doesn't work as the item is measured with infinity constraints. (Ibd3b2, b/162248854)
  • Removed SemanticsNodeInteraction.performPartialGesture. Use SemanticsNodeInteraction.performGesture instead. (Id9b62)
  • LazyColumnItems was renamed to LazyColumnFor. LazyRowItems was renamed to LazyRowFor (I84f84)
  • foundation.shape.corner package was flattened to foundation.share (I46491, b/161887429)
  • Renamed AndroidComposeTestRule to createAndroidComposeRule. (I70aaf)
  • Added more APIs to TextLayoutResult. (Id7e04)
  • Material FilledTextField was renamed to TextField and foundational TextField was renamed to BaseTextField to make simplest desired API easy to discover and use (Ia6242, b/155482676)
  • Modifier.drawBackground has been renamed to Modifier.background (I13677)

Version 0.1.0-dev15

July 22, 2020

androidx.compose.ui:ui-*:0.1.0-dev15 is released. Version 0.1.0-dev15 contains these commits.

Dependencies Update

  • To use the 0.1.0-dev15 version of Compose, you will need to update your dependencies according to the new code snippets shown above in Declaring dependencies.

API Changes

  • FocusModifier is deprecated in favor of Modifier.focus, Modifier.focusRequester, Modifier.focusObserver. FocusState and FocusDetailedState are deprecated in favor of FocusState2 (I46919, b/160822875, b/160922136)
  • Added a modifier to observe focus state change. (I05866, b/160924455, b/160923326)
  • Added a modifier to request focus changes (I8dd73, b/161182057, b/160924778)
  • Ajdust the Toolbar Menu to show copy, cut, paste properly. (Id3955)
  • Single-value semantics properties now use a calling style. For example, 'semantics { hidden = true }' is now written as: semantics { hidden() }. (Ic1afd, b/145951226, b/145955412)
  • Added Modifier.focus which replaces FocusModifier. (Ib852a, b/160924778)
  • Add FloatingToolbar for TextField Selection. (Ie8b07)
  • Added an experimental api annotation for key input related API (I53c0a)
  • Added an experimental api annotation for all Focus-related API (I53b24, b/160903352)
  • Added FocusState2 which will replace FocusDetailedState (I0a3ba, b/160822595)
  • Added ExperimentalFocus which is an @OptIn annotation for Focus API. (I1544b, b/160820961)
  • An IntBounds unit class has been added, representing integer pixel bounds from layout. The API of PopupPositionProvider has been updated to use it. (I0d8d0, b/159596546)
  • Applier now requires a clear() method for disposing compositions (Ibe697)
  • KeyEvent is deprecated and replaced by KeyEvent2 (I68730)
  • A new optional flag useUnmergedTree was added to test finders. (I2ce48)
  • Made LayoutNode experimental API (I4f2e9)
  • Added copy methods to various inline class types including:

    • Offset
    • Size
    • Radius
    • Motion
    • TransformOrigin

    • Deprecated Size.copy companion object method favor of instance copy method (Ife290, b/159905651)

  • Popups, Dialogs and Menus are now inheriting the contextual MaterialTheme (Ia3665, b/156527485)

  • TextDirection is renamed as ResolvedTextDirection (I3ff38)

  • Removed layout direction parameter from the measure block of the Layout() function. Layout direction is however available inside the callback through the measure scope object (Ic7d9d)

  • Refactor SelectionHandles for reusing. (I420e0)

  • Clickable was removed. Use Modifier.clickable (I84bdf)

  • TestTag and Semantics have been deleted. Use Modifier.testTag and Modifier.semantics instead (I15ff0, b/158841414)

  • Prior to this change, the compose compiler plugin would non-trivially intercept calls to constructors inside of a @Composable function if there was an (I5205a, b/158123804)

  • Modifier.tag was renamed to Modifier.layoutId, to avoid confusion with Modifier.testTag. (I995f0)

  • Alignment line Int positions returned from Placeable#get(AlignmentLine) are now non-null. If the queried alignment line is missing, AlignmentLine.Unspecified will be returned. (I896c5, b/158134875)

  • The AndroidView composable was added a modifier parameter. (I48a88, b/158746303)

  • Semantics() is deprecated. Use Modifier.semantics() instead. (I72407, b/158841414)

  • Add viewModel() composable which allows to create or get already created ViewModel similarly to how it works in Activity or Fragment (I5fdd1)

  • Replaced usage of IntPx with Int. Replaced IntPxPosition with IntOffset. Replaced IntPxSize with IntSize. (Ib7b44)

  • In order to consolidate the number of classes used to represent sizing information, standardize on usage of the Size class instead of PxSize. This provides the benefits of an inline class to leverage a long to pack 2 float values to represent width and height represented as floats. (Ic0191)

  • In order to consolidate the number of classes used to represent positioning information, standardize on usage of the Offset class instead of PxPosition. This provides the benefits of an inline class to leverage a long to pack 2 float values to represent x and y offsets represented as floats. (I3ad98)

  • Replaced usage of Px class in various compose classes as part of the large refactoring effort to only rely on Dp and primitive types for pixel parameters. Deleted Px class in its entirety (I3ff33)

  • Replaced usage of Px class in various compose classes as part of the large refactoring effort to only rely on Dp and primitive types for pixel parameters (I086f4)

  • Replaced usage of Px class in various compose classes as part of the large refactoring effort to only rely on Dp and primitive types for pixel parameters (Id3434)

  • Replaced usage of Px class in various compose classes as part of the large refactoring effort to only rely on Dp and primitive types for pixel parameters (I97a5a)

  • TestTag is now deprecated. Use Modifier.testTag instead. (If5110, b/157173105)

  • The default, no-op, implementation of ParentDataModifier#modifyParentData has been removed - it was equivalent to not implementing the interface in the first place. (I0deaa)

  • Previously deprecated ScaleFit as removed. Use ContentScale instead. (Ifbc5b)

  • Replaced usage of Px class in various compose classes as part of the large refactoring effort to only rely on Dp and primitive types for pixel parameters (I19d02)

  • Added the DropdownMenu component in ui-material, a Material Design menu implementation. (I9bb3d)

  • Removed deprecated LayoutTag(), please use Modifier.tag() instead. Removed deprecated Modifier.matchParent(), please use Modifier.matchParentSize() instead. (If8044)

  • Replaced usage of Px class in various compose classes as part of the large refactoring effort to only rely on Dp and primitive types for pixel parameters (I57bff)

  • Modifier.semantics has been undeprecated to allow usages for high level components. (I4cfdc)

  • Consolidated CanvasScope implementations so there is now just DrawScope and ContentDrawScope Renamed CanvasScope to DrawScope. Updated DrawScope to implement Density interface and provide LayoutDirection Deleted DrawScope subclass in ContentDrawScope Painter and PainterModifier have been updated to no longer maintain an RTL property themselves as DrawScope provides this already without manually providing it (I1798e)

  • DoubleTapGestureFilter now disambiguates SingleTapGestureFilter across the tree. (If92b1)

  • Updated Alignment API and added support for absolute alignment (which does not auto-mirror in Rtl context) (I38cd3)

  • DrawLayer modifiers api has been changed: outlineShape renamed to shape and has the RectangleShape default value and now non-nullable; clipToOutline renamed to clip; clipToBounds removed as it is the same as clip == true with RectangleShape (I7ef11, b/155075735)

  • Updated higher level compose APIs that expose a Canvas to expose CanvasScope instead. This removes the need for consumers to maintain their own Paint objects. For consumers that still require access to a Canvas they can use the drawCanvas extension method which provides a callback to issue drawing commands with the underlying Canvas. (I80afd)

  • WithConstraints trailing lambda API has been changed. Now instead of two params it has a receiver scope which in addition to constraints and layoutDirection provides minWidth, maxWidth, minHeight and maxHeight properties in Dp (I91b9a, b/149979702)

  • Renamed LayoutModifier2 to LayoutModifier. (Id29f3)

  • Removed deprecated LayoutModifier interface. (I2a9d6)

  • Intrinsic measurements functions in Layout and LayoutModifier2 have an IntrinsicMeasureScope receiver now which provides intrinsics query API with implicitly propagated layout direction. (Id9945)

  • Layout and LayoutModifier children can be measured with a different layout direction. (Ibd731)

  • New Modifier.zIndex() is added to control the drawing order of the children within the same parent layout. elevation property on DrawLayerModifier is renamed to shadowElevation and doesn't control the drawing order anymore. The params order fo DrawShadow is changed: elevation is now the first one and the shape is the second one with a RectangleShape default. (I20150, b/152417501)

  • Removed onSizeChange and onPositionChange in Owner. (I5c718)

  • Added Constraints2, a copy of Constraints that does only supports Int connstraints values rather than IntPx. IntPx will be removed and all integer constraints will be assumed to be pixels like Android.

    • Added IntSize as well, which will eventually replace IntPxSize. (I4b43a)
  • Made Alignment instantiable with arbitrary values. Added 1D Alignments. (Ia0c05)

  • alignToSiblings now accepts a Measured instead of Placeable. (I5788d)

  • (I45f09, b/152842521)

    • Renamed ScaleFit to ContentScale
    • Moved ContentScale from ui-graphics to ui-core module to live in the same module as the Alignment API.
    • Renamed FillMaxDimension to Crop
    • Renamed FillMinDimension to Fit
    • Renamed Fit to Inside to better match
    • ImageView.ScaleType equivalents
    • Added documentation indicating that the combination of Crop and Alignment.Center achieves the same result as ImageView.ScaleType.CENTER_CROP and Fit used with Alignment.Center achieves the same result as ImageView.ScaleType.FIT_CENTER Inside used with Alignment.Center achieves the same result as ImageView.ScaleType.CENTER_INSIDE
  • Rtl support for draw modifiers. (I0aaf9)

  • Released API for inflating Android Views from XML. See ViewInCompose demo for more details. (I42916)

  • Improve DrawModifier API:

    • Made the receiver scope for draw() ContentDrawScope
    • Removed all parameters on draw()
    • DrawScope has same interface as former CanvasScope
    • ContentDrawScope has drawContent() method (Ibaced, b/152919067)
  • Added positionInParent and boundsInParent for LayoutCoordinates. (Icacdd, b/152735784)

  • DrawLayerModifier and drawLayer() now default clipToBounds and clipToOutline to false. (I0eb8b, b/152810850)

  • Renamed LayoutResult to MeasureResult. (Id8c68)

  • Added LayoutModifier2, a new API for defining layout modifiers; deprecated LayoutModifier (If32ac)

  • Replaced Modifier plus operator with factory extension functions (I225e4)

  • Added translationX/Y properties to support offseting the display list of drawing commands for a given Layer. This is useful to move content in response to animations or touch events. (I8641c)

  • Added pivotX, pivotY parameters to Layer APIs to support rotation and scaling around a particular point on a layer (Icf7c3)

  • Add OnPositionedModifier and OnChildPositionedModifier to replace OnPositioned and OnChildPositioned composable functions. (I2ec8f)

  • Added LayerModifier, a modifier that allows adding a RenderNode for a Layout. It allows setting clipping, opacity, rotation, scaling, and shadows. This will replace RepaintBoundary. (I7100d, b/150774014)

  • Made the layout direction be propagated from parent layout node to children. Added layout direction modifier. (I3d955)

  • Stack component supports right-to-left directionality (Ic9e00)

  • Initial support for Rtl in Compose layout (Ia5519)

  • Density and DensityScope were merged into one interface. Instead of ambientDensity() you can now use DensityAmbient.current. Instead of withDensity(density) just with(density) (I11cb1)

  • Changed LayoutCoordinates to make providedAlignmentLines a Set instead of a Map and have LayoutCoordinates implement the get() operator instead for retrieving a value. This makes it easier for modifiers to modify one or more value of the set without creating a new collection for each modifier. (I0245a)

  • LayoutCoordinates no longer has a position property. The position property does not make sense when considering LayoutModifiers, rotation, or scaling. Instead, developers should use parentCoordinates and childToLocal() to calculate the transform from one LayoutCoordinate to another.

    LayoutCoordinates uses IntPxSize for the size property instead of PxSize. Layouts use integer pixel sizes for layouts, so all layout sizes should use integers and not floating point values. (I9367b)

  • Improvements to the API surface of Constraints (I0fd15)

  • Created CanvasScope API that wraps a Canvas object to expose a stateless, declarative drawing API surface. Transformations are contained within their own receiver scope and sizing information is also scoped to corresponding inset bounds. It does not require a consumer to maintain its own Paint state object for configuring drawing operations.

    • Added CanvasScopeSample as well as updated the demo app to include a declarative graphics demo (Ifd86d)
  • Removed unused MaskFilter API as it has limited usage and is not optimized for hardware acceleration in most use cases (I54f76)

  • RectangleShape moved from androidx.ui.foundation.shape.* to androidx.ui.graphics.* (Ia74d5, b/154507984)

  • Replaced all nullable Color uses in API with non-nullable and use Color.Unset instead of null (Iabaa7)

  • Introduce additional optional rect parameter to ImagePainter to support drawing a subsection of underlying ImageAsset (I0ea9e)

  • Added Unset Color to represent an unset value without boxing Colors. (If901a)

  • Added Canvas.rotate and Canvas.scale extension methods to consume optional pivot coordinates for transformations. These default to the top left corner of the current canvas translation.

    Also moved Canvas.rotateRad to be an extension method for consistency (Ibaca6)

  • Created PixelMap API to support querying pixel information from an ImageAsset. (I69ad6)

  • Renamed toFrameworkRect/toFrameworkRectF to toAndroidRect/toAndroidRectF to match naming convention for object conversions between compose and the Android framework APIs they are built on top of. Also updated docs on these APIs (I86337)

  • Added VectorPainter API to replace existing subcomposition API for vector graphics. Result of subcomposition is a VectorPainter object instead of a DrawModifier. Deprecated previous DrawVector composables in favor of VectorPainter.

    Renamed Image(Painter) API to PaintBox(Painter) Created Vector composable that behaves like the Image composable except with a VectorAsset instead of an ImageAsset (I9af9a, b/149030271)

  • Renamed Image to ImageAsset to better differentiate the difference between the Image data and the upcoming Image composable used to participate in layout and draw content. _Body:Created extension method on android.graphics.Bitmap, Bitmap.asImageAsset(), to create an instance of an ImageAsset useful for combining traditional Android application development with the compose framework (Id5bbd)

  • Added TextDirection.Content (I48f36)

  • Added TextDecoration.plus operator (I0ad1a)

  • Force is removed from TextDirectionAlgorithm enum values (Icc944)

  • TextDirectionAlgorithm is renamed as TextDirection (I75ce8)

  • Implements LongPressAndDrag for TextField Selection. (I17919)

  • Added AnnotatedString.getStringAnnotations that returns all annotations within the range. (I1fa00)

  • Changed the package name for Locale and LocaleList from androidx.ui.text to androidx.ui.intl (I8132c)

  • TextField's cursor has a blinking animation (Id10a7)

  • API change: AnnotatedString(builder: Builder) is renamed to annotatedString(builder: Builder). (Ia6377)

  • API change: AnnotatedString.Item is renamed to AnnotatedString.Range. (I2d44d)

  • Rename AnnotatedString.Builder.addAnnotationString to addStringAnnotation. (I5059e)

  • Now it is possible to hide/show software keyboard by using SoftwareKeyboardController which is delivered by onTextInputStarted callback (I8dc44, b/151860051)

  • Added plus operator for (Text/Paragraph/Span)Style which delegates to merge() function. (Ia1add)

  • FontWeight.lerp does not snap anymore. It is still a data class. (I521c2)

  • FontWeight constructor is now public, it is not data class anymore. (Id6b1f)

  • Add getLineStart, getLineEnd, getEllipsisOffset and getEllipsisCount to TextLayoutResult (Ibc801)

  • ui-text module is renamed as ui-text-core (I57dec)

  • Removed unused Size class as there is a duplicate Size class in the ui-geometry module that is being consumed. (I1b602)

  • Added AdapterList, a scrolling list component that only composes and lays out the visible items. Currently known issues include that it is vertical-only and does not fully handle all cases of changes to its children. (Ib351b)

  • Add paddings, border, shape and background param to Box (I05027, b/148147281)

Bug Fixes

  • onFocusChange callback in text fields renamed to onFocusChanged (Ida4a1)
  • VerticalScroller and HoriziontalScroller have been deprecated. Use ScrollableColumn and ScrollableRow for build-in experience with Column/Row behaviour and parameters, or Modifier.verticalScroll and Modifier.horizontalScroll on your own element. Similarly, ScrollerPosition has been deprecated in favor of ScrollState' (I400ce, b/157225838, b/149460415, b/154105299)
  • runOnIdleCompose renamed to runOnIdle (I83607)
  • Several testing APIs were renamed to be more intuitive. All findXYZ APIs were renamed to onNodeXYZ. All doXYZ APIs were renamed to performXYZ. (I7f164)
  • Compose UI can now be composed inside ViewGroups without requiring a new composition. See ViewInteropDemo for an example. (I9ab0b, b/160455080)
  • Added sortWith and removeRange to MutableVector (Icccf7)
  • Implement Drag Selection Handles to change selection for TextField. (I27032)
  • Removed Shader inline class that wrapped the NativeShader expect class Renamed NativeShader to Shader. The wrapped Shader inline class did not add anything valuable to the API surface and was an inline class, so use the NativeShader class directly. (I25e4d)
  • Refactored PainterModifier to no longer provide scaling based on the given constraints and ContentScale parameter. Implementations of Painter are to scale their drawing content themselves based on the given size of the DrawScope they are drawing into.

    Fixed issue where VectorPainter's cache bitmap was sized to its default size instead of the given size to draw into.

    Updated ImagePainter to scale its content instead of relying on PainterModifier to do so on its behalf. (I6ba90)

  • add top-level withFrameNanos function for animation timing (Ie34c5)

  • @Untracked annotation has been deprecated. Replace with @ComposableContract(tracked=false) (Id211e)

  • androidx.ui.foundation.TextFieldValue and androidx.ui.input.EditorValue is deprecated. TextField, FilledTextField and CoreTextField composables that uses that type is also deprecated. Please use androidx.ui.input.TextFieldValue instead (I4066d, b/155211005)

  • Fixed issue where pointer input dispatch would cause a crash if PointerInputFilters were removed via subcomposition during disptach. This is now fixed. (I1f48b, b/157998762)

  • Fixed issue where pointer input dispatch would cause a crash if PointerInputFilters were removed via subcomposition during disptach. This is now fixed. (Iab398, b/157998762)

  • Refactored Radius class to be an inline class. Removed companion creation methods in favor of function constructor with default parameter to have the radius along the y-axis match that of the mandatory x-axis radius parameter.

    Updated DrawScope.drawRoundRect to consume a single Radius parameter instead of 2 separate float values for the radius along the x and y axis (I46d1b)

  • The Recompose composable is no longer a useful abstraction. Most recomposition should happen as a result of MutableState assignments. For anything beyond that, it is recommended that you use the invalidate function to trigger a recomposition of the current scope. (Ifc992)

  • Replaced usage of Px class in various compose classes as part of the large refactoring effort to only rely on Dp and primitive types for pixel parameters (Iede0b)

  • Changes the code generation strategy of Compose’s compiler. Prior to the change, the compose compiler would transform calls to composable functions. With this change, we now transform the body of a composable function and leave the callsite unaltered (mostly).

    This means that most of the logic communicating with the compose runtime happens at the start of the function body, instead of at the callsite.

    This should be a source-compatible change for all usage of compose. Most users of compose should not have to update any code as a result of this change.

    In order to support this work, the JVM signature of all composable functions has changed. A Composable function accepting a single parameter is transformed into a function accepting 3 parameters, the additional parameters are the Composer, a ‘key’ integer. a bitmask integer used to propagate metadata through calls.

    Compose now also transforms default arguments to a composable function. It does this without introducing an additional synthetic default overload of the function itself, so this change will result in fewer functions being defined.

    Known intentional behavioral changes resulting from this:

    1. Some calls will skip where they wouldn’t have previously
    2. Composable expressions in default argument expressions are now correctly subscribed to and handled

    This work included some optimizations: 1. The result of comparisons of parameters are propagated through the call graph to other composable functions. This will result in fewer comparisons at runtime, reduces the slot table size, as well as more skipping of composable functions that were previously not skipped 2. Paremeters which are determined to be “static” at compile time are no longer compared or stored in the runtime. This reduces the number of comparisons and reduces slot table size. 3. Control flow structure of the body of functions is used to minimize the number of groups that are generated. This reduces slot table size and results in less work for the runtime 4. Unused dispatch and receiver parameters to functions are not included in determining skippability of the function if they are not used inside of the body of the function.

    Most breaking changes were for APIs that the compiler targets directly, and typical use of compose will not be affected: 1. Composer::startExpr was removed 2. Composer::endExpr was removed 3. Composer::call was deprecated 4. The non-varargs overloads of key have been removed. Use the vararg version going forward. 5. The Pivotal annotation was deprecated. Use key as a replacement. 6. ScopeUpdateScope::updateScope was changed to expect a Function3 instead of Function1 7. restartableFunction and restartableFunctionN were updated to include additional compile time parameters (I60756, b/143464846)

  • Removed deprecated LayoutAlign modifiers. (I10877)

  • Removed RepaintBoundary in favor of DrawLayerModifier (I00aa4)

  • Button, FloatingActionButton and Clickable now have a separate enabled param. Some of the params on Button were renamed or reordered. (I54b5a)

  • Replaced ButtonStyle with distinct functions and removed text (string) overload. See updated samples for usage information. (If63ab, b/146478620, b/146482131)

  • Breaking changes to the ambients API. See log and Ambient<T> documentation for details (I4c7ee, b/143769776)

  • Changed the behavior of default TextDirection to be determined by LayoutDirection. i.e. If LayoutDirection is RTL, default TextDirection will be RTL. Previously it was TextDirection.ContentOrLtr/Rtl (I4e803)

  • Bug fix: When font weight and font style are nested on an AnnotatedString, text is not rendered correctly. (I77a9d)

  • Adds commonly used parameters to Text(). If you are currently creating a local text style to pass a small number of these parameters, such as Text(style = TextStyle(textAlign = TextAlign.Center)), you can now just provide the parameters directly: Text(textAlign = TextAlign.Center) (I82768)

  • ui-android-text module is renamed as ui-text-android (I68cbe)