Last active
June 24, 2022 10:32
-
-
Save TemMax/183f393450c284a96c99eec0c9744708 to your computer and use it in GitHub Desktop.
A little hack when you want to use layer type for composable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.view.View | |
import androidx.compose.runtime.Composable | |
import androidx.compose.ui.Modifier | |
import androidx.compose.ui.platform.ComposeView | |
import androidx.compose.ui.viewinterop.AndroidView | |
@Composable | |
fun SoftwareLayerComposable( | |
modifier: Modifier = Modifier, | |
content: @Composable () -> Unit | |
) { | |
AndroidView( | |
factory = { context -> | |
ComposeView(context).apply { | |
setLayerType(View.LAYER_TYPE_SOFTWARE, null) | |
} | |
}, | |
update = { composeView -> | |
composeView.setContent(content) | |
}, | |
modifier = modifier | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment