当前位置:网站首页>Kotlin compose implicitly passes the parameter compositionlocalprovider
Kotlin compose implicitly passes the parameter compositionlocalprovider
2022-06-27 03:48:00 【Ango cannot move】
Code
package com.anguomob.jecpack.activity.compose.composition.local
import androidx.compose.foundation.layout.Column
import androidx.compose.material.ContentAlpha
import androidx.compose.material.LocalContentAlpha
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.platform.LocalContext
@Composable
fun CompositionSample2() {
MaterialTheme() {
Column() {
Text(text = "sadjkllllasdkljaskljdasjkldaskjldajlk")
CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) {
Text(text = "sadjkllllasdkljaskljdasjkldaskjldajlk")
Text(text = "sadjkllllasdkljaskljdasjkldaskjldajlk")
CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.disabled) {
DescendantExample()
}
}
CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.disabled) {
DescendantExample()
}
}
}
}
@Composable
fun DescendantExample() {
Text(text = "sadjkllllasdkljaskljdasjkldaskjldajlk")
}style

In this scenario, you often get the context
@Composable
fun FruitText(fruitSize: Int) {
val res = LocalContext.current.resources
val fruitText = res.getQuantityString(R.plurals.fruit_title, fruitSize)
Text(text = "${fruitSize} ${fruitText}")
}LocalContext.current

边栏推荐
猜你喜欢

QIngScan使用

Il manque beaucoup de fichiers et de répertoires tels que scripts pendant et après l'installation d'anaconda3

Kotlin Compose 自定义 CompositionLocalProvider CompositionLocal

2021:Graphhopper: Multi-Hop Scene Graph Reasoning for Visual Question Answering

PAT甲级 1020 Tree Traversals

Pat grade a 1026 table tennis

Is the truth XX coming? Why are test / development programmers unwilling to work overtime? This is a crazy state

There are two problems when Nacos calls microservices: 1 Load balancer does not contain an instance for the service 2. Connection refused

Super detailed, 20000 word detailed explanation, thoroughly understand es!

2021:Greedy Gradient Ensemble for Robust Visual Question Answering
随机推荐
Semantic version 2.0.0
PAT甲级 1024 Palindromic Number
投资理财产品的钱有保障吗?会不会没有了?
2022 Chinese pastry (Advanced) recurrent training question bank and online simulation test
Knowledge of iPhone certificate structure
CVPR2021:Separating Skills and Concepts for Novel Visual Question Answering将技巧与概念分开的新视觉问答
resnet152 辣椒病虫害图像识别1.0
MySql的开发环境
733. image rendering
Network structure and model principle of convolutional neural network (CNN)
Quicksand painting simulator source code
Anaconda3安装过程及安装后缺失大量文件,没有scripts等目录
Fplan powerplan instance
手机新领域用法知识
面试-01
2021:Graphhopper: Multi-Hop Scene Graph Reasoning for Visual Question Answering
I found a JSON visualization tool artifact. I love it!
Super detailed, 20000 word detailed explanation, thoroughly understand es!
Implementation of window encryption shell
SAI钢笔工具如何使用,入门篇