androidx.compose.ui.unit
Dp
Value class · from org.jetbrains.compose.ui:ui-unit:1.12.2
No hand-written docs yet.
Dimension value representing device-independent pixels (dp). Component APIs specify their dimensions such as line thickness in DP with Dp objects. Hairline (1 pixel) thickness may be specified with Hairline, a dimension that take up no space. Dp are normally defined using dp, which can be applied to Int, Double, and Float.
value class Dp(
value: Float,
) : Comparable<Dp>
Is a
Comparable
How to get one
Create it
Dp(value)constructor
Ready-made values and functions that return it
AlertDialogDefaults:IconSize,TonalElevationArrangement.Horizontal:spacingArrangement.Vertical:spacingAssistChipDefaults:Height,IconSize,HorizontalSpacingBottomAppBarDefaults:ContainerElevation,FlexibleBottomAppBarHeightexpBottomSheetDefaults:Elevation,SheetPeekHeight,SheetMaxWidthBoxWithConstraintsScope:minWidth,maxWidth,minHeight,maxHeightButtonDefaults:MinWidth,MinHeight,ExtraSmallContainerHeight,MediumContainerHeight,LargeContainerHeight,ExtraLargeContainerHeight,IconSize,ExtraSmallIconSize,SmallIconSize,MediumIconSize,LargeIconSize,ExtraLargeIconSize,IconSpacing,ExtraSmallIconSpacing,MediumIconSpacing,LargeIconSpacing,ExtraLargeIconSpacing,iconSizeFor(),iconSpacingFor()ButtonGroupDefaults:ConnectedSpaceBetweenCarouselDefaults:MinSmallItemSize,MaxSmallItemSizeContextualFlowColumnScope:maxWidth,maxHeightInLineContextualFlowRowScope:maxWidthInLine,maxHeightDatePickerDefaults:TonalElevationDensity:toDp()DividerDefaults:ThicknessDpOffset:x,yDpSize:width,height,component1(),component2()DrawerDefaults:ModalDrawerElevation,PermanentDrawerElevation,DismissibleDrawerElevation,MaximumDrawerWidthFilterChipDefaults:Height,IconSize,HorizontalSpacing,CompactHorizontalSpacingFloatingActionButtonDefaults:MediumIconSize,LargeIconSizeFloatingToolbarDefaults:ContainerSize,ContainerExpandedElevation,ContainerCollapsedElevation,ContainerExpandedElevationWithFab,ContainerCollapsedElevationWithFab,ScreenOffset,ScrollDistanceThresholdFontScaling:toDp()IconButtonDefaults:extraSmallIconSize,smallIconSize,mediumIconSize,largeIconSize,extraLargeIconSizeInputChipDefaults:Height,IconSize,AvatarSize,HorizontalSpacing,CompactHorizontalSpacingListItemDefaults:Elevation,SegmentedGapexp
23 more
LoadingIndicatorDefaults:ContainerWidth,ContainerHeight,IndicatorSizeMenuDefaults:TonalElevation,ShadowElevation,LeadingIconSize,TrailingIconSize,GroupSpacingNavigationBarDefaults:ElevationOutlinedTextFieldDefaults:MinHeight,MinWidth,UnfocusedBorderThickness,FocusedBorderThicknessPaddingValues:calculateLeftPadding(),calculateTopPadding(),calculateRightPadding(),calculateBottomPadding()PaneScaffoldParentData:preferredWidth,preferredHeight,minTouchTargetSizeProgressIndicatorDefaults:CircularStrokeWidth,LinearTrackStopIndicatorSizeexp,LinearIndicatorTrackGapSizeexp,CircularIndicatorTrackGapSizeexpPullToRefreshDefaults:PositionalThreshold,Elevation,LoadingIndicatorElevationScrollbarDefaults:Thickness,ThumbMinLength,MainAxisTrackInset,CrossAxisTrackInsetSearchBarDefaults:TonalElevation,ShadowElevation,InputFieldHeight,dockedDropdownGapSizeSegmentedButtonDefaults:BorderWidth,IconSizeSliderDefaults:TrackStopIndicatorSize,TickSizeSplitButtonDefaults:LeadingIconSize,TrailingIconSize,Spacing,ExtraSmallTrailingButtonIconSize,SmallTrailingButtonIconSize,MediumTrailingButtonIconSize,LargeTrailingButtonIconSize,ExtraLargeTrailingButtonIconSize,SmallContainerHeight,ExtraSmallContainerHeight,MediumContainerHeight,LargeContainerHeight,ExtraLargeContainerHeight,leadingButtonIconSizeFor(),trailingButtonIconSizeFor()SuggestionChipDefaults:Height,IconSize,HorizontalSpacingTabPosition:rightTabRowDefaults:ScrollableTabRowMinTabWidth,ScrollableTabRowEdgeStartPaddingTextFieldDefaults:MinHeight,MinWidth,UnfocusedIndicatorThickness,FocusedIndicatorThicknessTimePickerDialogDefaults:MinHeightForTimePickerToggleButtonDefaults:MinHeight,IconSpacing,IconSizeTooltipDefaults:plainTooltipMaxWidth,richTooltipMaxWidthTopAppBarDefaults:TopAppBarExpandedHeight,MediumAppBarCollapsedHeight,MediumAppBarExpandedHeight,MediumFlexibleAppBarWithoutSubtitleExpandedHeight,MediumFlexibleAppBarWithSubtitleExpandedHeight,LargeAppBarCollapsedHeight,LargeAppBarExpandedHeight,LargeFlexibleAppBarWithoutSubtitleExpandedHeight,LargeFlexibleAppBarWithSubtitleExpandedHeightWavyProgressIndicatorDefaults:LinearDeterminateWavelength,LinearIndeterminateWavelength,LinearContainerHeight,LinearContainerWidth,LinearTrackStopIndicatorSize,CircularContainerSize,CircularWavelength,LinearIndicatorTrackGapSize,CircularIndicatorTrackGapSizedpwidthheightVisibilityThreshold
Used by
Parameters that take a Dp.
AbsoluteCutCornerShape(size, topLeft, topRight, bottomRight, bottomLeft)absoluteOffset(x, y)absolutePadding(left, top, right, bottom)AbsoluteRoundedCornerShape(size, topLeft, topRight, bottomRight, bottomLeft)AlertDialog(tonalElevation)AppBarWithSearch(tonalElevation, shadowElevation)Arrangement.spacedBy(space)AssistChipDefaults.horizontalArrangement(spacing)basicMarquee(velocity)blur(radiusX, radiusY, radius)border(width)BorderStroke(width)BorderStroke.copy(width)BottomAppBar(tonalElevation)BottomSheet(maxWidth, tonalElevation, shadowElevation)BottomSheetDefaults.DragHandle(width, height)BottomSheetScaffold(sheetPeekHeight, sheetMaxWidth, sheetTonalElevation, sheetShadowElevation)ButtonDefaults.contentPaddingFor(buttonHeight)ButtonDefaults.iconSizeFor(buttonHeight)ButtonDefaults.iconSpacingFor(buttonHeight)CenterAlignedTopAppBar(expandedHeight)CircularProgressIndicator(strokeWidth, gapSize)CircularWavyProgressIndicator(gapSize, wavelength, waveSpeed)ContextualFlowColumnOverflow.expandOrCollapseIndicator(minWidthToShowCollapse)ContextualFlowRowOverflow.expandOrCollapseIndicator(minHeightToShowCollapse)CornerSize(size)CutCornerShape(size, topStart, topEnd, bottomEnd, bottomStart)DatePickerDialog(tonalElevation)defaultMinSize(minWidth, minHeight)DismissibleDrawerSheet(drawerTonalElevation)
150 more
DockedSearchBar(tonalElevation, shadowElevation)Dp.div(other)Dp.minus(other)Dp.plus(other)DpOffset(x, y)DpOffset.copy(x, y)DpSize(width, height)DpSize.copy(width, height)DropdownMenu(tonalElevation, shadowElevation)DropdownMenuGroup(tonalElevation, shadowElevation)ExpandedDockedSearchBar(tonalElevation, shadowElevation)ExpandedDockedSearchBarWithGap(dropdownGapSize, tonalElevation, shadowElevation)ExpandedFullScreenContainedSearchBar(tonalElevation, shadowElevation)ExpandedFullScreenSearchBar(tonalElevation, shadowElevation)ExposedDropdownMenuBoxScope.ExposedDropdownMenu(tonalElevation, shadowElevation)FilterChipDefaults.horizontalArrangement(spacing)FlexBoxConfigScope.columnGap(value)FlexBoxConfigScope.gap(all, row, column)FlexBoxConfigScope.rowGap(value)FlexConfigScope.basis(value)FlexibleBottomAppBar(expandedHeight)FloatingActionButtonDefaults.bottomAppBarFabElevation(defaultElevation, pressedElevation, focusedElevation, hoveredElevation)FloatingToolbarDefaults.floatingToolbarVerticalNestedScroll(expandScrollDistanceThreshold, collapseScrollDistanceThreshold)FlowColumnOverflow.expandOrCollapseIndicator(minWidthToShowCollapse)FlowRowOverflow.expandOrCollapseIndicator(minHeightToShowCollapse)GridConfigurationScope.column(size)GridConfigurationScope.columnGap(gap)GridConfigurationScope.gap(all, row, column)GridConfigurationScope.minmax(min)GridConfigurationScope.row(size)GridConfigurationScope.rowGap(gap)height(height)heightIn(min, max)HorizontalCenteredHeroCarousel(maxItemWidth, itemSpacing, minSmallItemWidth, maxSmallItemWidth)HorizontalDivider(thickness)HorizontalFloatingToolbar(expandedShadowElevation, collapsedShadowElevation)HorizontalMultiBrowseCarousel(preferredItemWidth, itemSpacing, minSmallItemWidth, maxSmallItemWidth)HorizontalPager(pageSpacing)HorizontalUncontainedCarousel(itemWidth, itemSpacing)InputChipDefaults.horizontalArrangement(spacing)LargeFlexibleTopAppBar(collapsedHeight, expandedHeight)LargeTopAppBar(collapsedHeight, expandedHeight)LazyHorizontalStaggeredGrid(horizontalItemSpacing)LazyLayoutCacheWindow(ahead, behind)LazyVerticalStaggeredGrid(verticalItemSpacing)LinearProgressIndicator(gapSize)LinearWavyProgressIndicator(gapSize, stopSize, wavelength, waveSpeed)ListItem(tonalElevation, shadowElevation)ListItemDefaults.elevation(elevation, draggedElevation)MediumFlexibleTopAppBar(collapsedHeight, expandedHeight)MediumTopAppBar(collapsedHeight, expandedHeight)ModalBottomSheet(sheetMaxWidth, tonalElevation)ModalDrawerSheet(drawerTonalElevation)ModalWideNavigationRail(expandedHeaderTopPadding)MultiChoiceSegmentedButtonRow(space)NavigationBar(tonalElevation)offset(x, y)OutlinedTextFieldDefaults.Container(focusedBorderThickness, unfocusedBorderThickness)OutlinedTextFieldDefaults.contentPaddingWithLabel(start, top, end, bottom)OutlinedTextFieldDefaults.contentPaddingWithoutLabel(start, top, end, bottom)padding(start, top, end, bottom, horizontal, vertical, all)paddingFrom(before, after)paddingFromBaseline(top, bottom)PaddingValues(all, horizontal, vertical, start, top, end, bottom)PaneExpansionAnchor.Offset.fromEnd(offset)PaneExpansionAnchor.Offset.fromStart(offset)PaneScaffoldDirective.copy(horizontalPartitionSpacerSize, verticalPartitionSpacerSize, defaultPanePreferredWidth, defaultPanePreferredHeight)PaneScaffoldScope.paneExpansionDraggable(minTouchTargetSize)PaneScaffoldScope.preferredHeight(height)PaneScaffoldScope.preferredWidth(width)PermanentDrawerSheet(drawerTonalElevation)PlainTooltip(maxWidth, tonalElevation, shadowElevation)PrimaryScrollableTabRow(edgePadding, minTabWidth)ProgressIndicatorDefaults.drawStopIndicator(stopSize)pullToRefresh(threshold)PullToRefreshBox(threshold)PullToRefreshDefaults.Indicator(maxDistance)PullToRefreshDefaults.IndicatorBox(maxDistance, elevation)PullToRefreshDefaults.LoadingIndicator(elevation, maxDistance)rememberDragToResizeState(minSize, maxSize)requiredHeight(height)requiredHeightIn(min, max)requiredSize(size, width, height)requiredSizeIn(minWidth, minHeight, maxWidth, maxHeight)requiredWidth(width)requiredWidthIn(min, max)RichTooltip(maxWidth, tonalElevation, shadowElevation)ripple(radius)SearchBar(tonalElevation, shadowElevation)SecondaryScrollableTabRow(edgePadding, minTabWidth)SingleChoiceSegmentedButtonRow(space)SliderDefaults.CenteredTrack(thumbTrackGapSize, trackInsideCornerSize, trackCornerSize)SliderDefaults.Track(thumbTrackGapSize, trackInsideCornerSize, trackCornerSize)scrollbar(thickness, thumbMinLength, mainAxisTrackInset, crossAxisTrackInset)SegmentedButtonDefaults.borderStroke(width)SliderDefaults.drawStopIndicator(size)SplitButtonDefaults.leadingButtonContentPaddingFor(buttonHeight)SplitButtonDefaults.leadingButtonIconSizeFor(buttonHeight)SplitButtonDefaults.trailingButtonContentPaddingFor(buttonHeight)SplitButtonDefaults.trailingButtonIconSizeFor(buttonHeight)SplitButtonLayout(spacing)SuggestionChipDefaults.horizontalArrangement(spacing)Surface(tonalElevation, shadowElevation)TopAppBar(expandedHeight)TwoRowsTopAppBar(collapsedHeight, expandedHeight)VerticalDivider(thickness)AssistChipDefaults.assistChipBorder(borderWidth)AssistChipDefaults.assistChipElevation(elevation, pressedElevation, focusedElevation, hoveredElevation, draggedElevation, disabledElevation)AssistChipDefaults.elevatedAssistChipElevation(elevation, pressedElevation, focusedElevation, hoveredElevation, draggedElevation, disabledElevation)ButtonDefaults.buttonElevation(defaultElevation, pressedElevation, focusedElevation, hoveredElevation, disabledElevation)ButtonDefaults.elevatedButtonElevation(defaultElevation, pressedElevation, focusedElevation, hoveredElevation, disabledElevation)ButtonDefaults.filledTonalButtonElevation(defaultElevation, pressedElevation, focusedElevation, hoveredElevation, disabledElevation)ButtonDefaults.shapesFor(buttonHeight)ButtonDefaults.textStyleFor(buttonHeight)CardDefaults.cardElevation(defaultElevation, pressedElevation, focusedElevation, hoveredElevation, draggedElevation, disabledElevation)CardDefaults.elevatedCardElevation(defaultElevation, pressedElevation, focusedElevation, hoveredElevation, draggedElevation, disabledElevation)CardDefaults.outlinedCardElevation(defaultElevation, pressedElevation, focusedElevation, hoveredElevation, draggedElevation, disabledElevation)FilterChipDefaults.elevatedFilterChipElevation(elevation, pressedElevation, focusedElevation, hoveredElevation, draggedElevation, disabledElevation)FilterChipDefaults.filterChipBorder(borderWidth, selectedBorderWidth)FilterChipDefaults.filterChipElevation(elevation, pressedElevation, focusedElevation, hoveredElevation, draggedElevation, disabledElevation)FloatingActionButtonDefaults.elevation(defaultElevation, pressedElevation, focusedElevation, hoveredElevation)FloatingActionButtonDefaults.loweredElevation(defaultElevation, pressedElevation, focusedElevation, hoveredElevation)InputChipDefaults.inputChipBorder(borderWidth, selectedBorderWidth)InputChipDefaults.inputChipElevation(elevation, pressedElevation, focusedElevation, hoveredElevation, draggedElevation, disabledElevation)RoundedCornerShape(size, topStart, topEnd, bottomEnd, bottomStart)shadow(elevation)size(size, width, height)sizeIn(minWidth, minHeight, maxWidth, maxHeight)SplitButtonDefaults.leadingButtonShapesFor(buttonHeight)SplitButtonDefaults.trailingButtonShapesFor(buttonHeight)SuggestionChipDefaults.elevatedSuggestionChipElevation(elevation, pressedElevation, focusedElevation, hoveredElevation, draggedElevation, disabledElevation)SuggestionChipDefaults.suggestionChipBorder(borderWidth)SuggestionChipDefaults.suggestionChipElevation(elevation, pressedElevation, focusedElevation, hoveredElevation, draggedElevation, disabledElevation)surfaceColorAtElevation(elevation)TabRowDefaults.PrimaryIndicator(width, height)TabRowDefaults.SecondaryIndicator(height)TextFieldDefaults.Container(focusedIndicatorLineThickness, unfocusedIndicatorLineThickness)TextFieldDefaults.contentPaddingWithLabel(start, end, top, bottom)TextFieldDefaults.contentPaddingWithoutLabel(start, top, end, bottom)TextFieldDefaults.indicatorLine(focusedIndicatorLineThickness, unfocusedIndicatorLineThickness)ToggleFloatingActionButtonDefaults.containerCornerRadius(initialSize, finalSize)ToggleFloatingActionButtonDefaults.containerSize(initialSize, finalSize)ToggleFloatingActionButtonDefaults.iconSize(initialSize, finalSize)VerticalFloatingToolbar(expandedShadowElevation, collapsedShadowElevation)VerticalPager(pageSpacing)ToggleButtonDefaults.shapesFor(buttonHeight)TooltipDefaults.rememberTooltipPositionProvider(spacingBetweenTooltipAndAnchor)width(width)widthIn(min, max)WindowInsets(left, top, right, bottom)
Properties
Hairline
val Hairline: Dp
A dimension used to represent a hairline drawing element. Hairline elements take up no space, but will draw a single pixel, independent of the device's resolution and density.
Infinity
val Infinity: Dp
Infinite dp dimension.
Unspecified
val Unspecified: Dp
Constant that means unspecified Dp. Instead of comparing a Dp value to this constant, consider using isSpecified and isUnspecified instead.
value
val value: Float
Functions
plus
fun plus(other: Dp): Dp
Add two Dps together.
minus
fun minus(other: Dp): Dp
Subtract a Dp from another one.
unaryMinus
fun unaryMinus(): Dp
This is the same as multiplying the Dp by -1.0.
div
fun div(other: Float): Dp
Divide a Dp by a scalar.
fun div(other: Int): Dp
fun div(other: Dp): Float
Divide by another Dp to get a scalar.
times
fun times(other: Float): Dp
Multiply a Dp by a scalar.
fun times(other: Int): Dp
Library docs
Dimension value representing device-independent pixels (dp). Component APIs specify their
dimensions such as line thickness in DP with Dp objects. Hairline (1 pixel) thickness may be
specified with Hairline, a dimension that take up no space. Dp are normally defined using dp,
which can be applied to Int, Double, and Float.