Remote Compose Storybook English GitHub

alpha, rotate, scale, graphicsLayer · graphicsLayer { }

The block form of graphicsLayer.

alpha, rotate, scale, graphicsLayer · graphicsLayer { }: документ, нарисованный плеером Remote Compose
Открыть живое интерактивное демо →

Меняйте параметры, смотрите удалённый документ, который получается, и разницу после каждого изменения.

Что это

Делает элемент прозрачнее, поворачивает, масштабирует, наклоняет в 3D или добавляет тень — не сдвигая ничего вокруг.

Подходит для

  • Неактивные состояния (полупрозрачные)
  • Наклонённые и переворачивающиеся карточки
  • Акцент через увеличение

Код

Исходник примера с импортами androidx.compose.remote. CI компилирует каждый фрагмент кода на сайте против AndroidX.

import androidx.compose.remote.creation.compose.layout.RemoteAlignment
import androidx.compose.remote.creation.compose.layout.RemoteBox
import androidx.compose.remote.creation.compose.layout.RemoteComposable
import androidx.compose.remote.creation.compose.modifier.RemoteModifier
import androidx.compose.remote.creation.compose.modifier.alpha
import androidx.compose.remote.creation.compose.modifier.background
import androidx.compose.remote.creation.compose.modifier.graphicsLayer
import androidx.compose.remote.creation.compose.modifier.size
import androidx.compose.remote.creation.compose.state.rc
import androidx.compose.remote.creation.compose.state.rdp
import androidx.compose.remote.creation.compose.state.rf
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color

@Composable
@RemoteComposable
fun GraphicsLayerBlock(translationX: Float, translationY: Float, alpha: Float) {
    RemoteBox(RemoteModifier.size(260.rdp), contentAlignment = RemoteAlignment.Center) {
        RemoteBox(
            // The block form sets the same properties on a RemoteGraphicsLayerScope.
            RemoteModifier.graphicsLayer {
                    this.translationX = translationX.rf
                    this.translationY = translationY.rf
                    this.alpha = alpha.rf
                }
                .size(120.rdp)
                .background(Color(0xFF00ACC1).rc),
        )
    }
}

API

creation.compose.modifier.alpha

RemoteModifier alpha(RemoteModifier, RemoteFloat alpha)

creation.compose.modifier.rotate

RemoteModifier rotate(RemoteModifier, RemoteFloat degrees)

creation.compose.modifier.scale

RemoteModifier scale(RemoteModifier, RemoteFloat scale)
RemoteModifier scale(RemoteModifier, RemoteFloat scaleX, RemoteFloat scaleY)

creation.compose.modifier.graphicsLayer

RemoteModifier graphicsLayer(RemoteModifier, optional RemoteFloat scaleX, optional RemoteFloat scaleY, optional RemoteFloat rotationX, optional RemoteFloat rotationY, optional RemoteFloat rotationZ, optional RemoteFloat shadowElevation, optional RemoteFloat transformOriginX, optional RemoteFloat transformOriginY, optional RemoteFloat translationX, optional RemoteFloat translationY, optional RemoteFloat alpha, optional RemoteShape shape, optional RemoteCompositingStrategy compositingStrategy, optional RemoteFloat cameraDistance, optional RemoteRenderEffect? renderEffect)
RemoteModifier graphicsLayer(RemoteModifier, RemoteGraphicsLayerScope.() -> Unit block)

creation.compose.modifier.RemoteGraphicsLayerScope

interface RemoteGraphicsLayerScope
  RemoteFloat alpha
  RemoteFloat cameraDistance
  RemoteCompositingStrategy compositingStrategy
  RemoteRenderEffect? renderEffect
  RemoteFloat rotationX
  RemoteFloat rotationY
  RemoteFloat rotationZ
  RemoteFloat scaleX
  RemoteFloat scaleY
  RemoteFloat shadowElevation
  RemoteShape shape
  RemoteFloat transformOriginX
  RemoteFloat transformOriginY
  RemoteFloat translationX
  RemoteFloat translationY

Справочник

Другие примеры этого компонента

Ещё в разделе «Модификаторы»