Class

RemoteDp

Represents a Density-independent pixel (Dp) value.

RevenueCat

RevenueCat

Add subscriptions to your apps in minutes

Ad Get started for free
Android
public class RemoteDp
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
internal constructor(
    @get:RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) public val value: RemoteFloat
) : BaseRemoteState<Dp>()

Represents a Density-independent pixel (Dp) value.

RemoteDp represents a Dp value that can be a constant, a named variable, or a dynamic expression.

Functions

toPx

@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
    public fun toPx(density: RemoteDensity): RemoteFloat

Function to convert this RemoteDp to a density-independent pixel value. It multiplies the current float value by the screen\'s density.


toPx

public fun toPx(): RemoteFloat

Converts a RemoteDp to a RemoteFloat Px using the RemoteDensity.

Companion Object

Methods


invoke

Android
public operator fun invoke(value: Dp): RemoteDp

Creates a RemoteDp from a literal Dp value.

Parameters

value The Dp value.

Returns

A RemoteDp representing the constant Dp.

createNamedRemoteDp

Android
@JvmStatic
        public fun createNamedRemoteDp(
            name: String,
            defaultValue: Dp,
            domain: RemoteState.Domain = RemoteState.Domain.User,
        ): RemoteDp

Creates a named RemoteDp with an initial value.

Named remote Dps can be set via AndroidRemoteContext.setNamedFloat.

Parameters

name A unique name to identify this state within its domain.
defaultValue The initial Dp value for the named remote Dp.
domain The domain for the named state. Defaults to RemoteState.Domain.User.

Returns

A RemoteDp representing the named Dp.