当前位置:网站首页>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

边栏推荐
- Pat grade a 1019 general palindromic number
- mysql数据库基础:DQL数据查询语言
- 人间清醒:底层逻辑和顶层认知
- 电商产品如何在知乎上进行推广和打广告?
- Ldr6028 OTG data transmission scheme for mobile devices while charging
- 2019LXMERT:Learning Cross-Modality Encoder Representations from Transformers
- 2021:AdaVQA: Overcoming Language Priors with Adapted Margin Cosine Loss∗自适应的边缘余弦损失解决语言先验
- Nacos调用微服务两个问题:1.Load balancer does not contain an instance for the service 2.Connection refused
- Nestjs environment variable configuration to solve the problem of how to inject services into interceptors
- 如何系统学习LabVIEW?
猜你喜欢

Qingscan use

办公室VR黄片,骚操作!微软HoloLens之父辞职!

2021:adavqa: overlapping language priors with adapted margin cosine loss *

JMeter takes the result of the previous request as the parameter of the next request

ESP8266

2016Analyzing the Behavior of Visual Question Answering Models

LDR6028 手机设备一边充电一边OTG传输数据方案

Anaconda3 is missing a large number of files during and after installation, and there are no scripts and other directories

ERP demand and sales management Kingdee

PAT甲级 1021 Deepest Root
随机推荐
Servlet and JSP final review examination site sorting 42 questions and 42 answers
如何让 EF Core 6 支持 DateOnly 类型
通信中的机器学习最佳阅读资料列表
Description of replacement with STM32 or gd32
Pat grade a 1025 pat ranking
Mobilenet series (4): mobilenetv3 network details
ERP需求和销售管理 金蝶
TP5 Spreadsheet Excle 表格导出
2021:Check it again:Progressive Visual Question Answering via Visual Entailment通过视觉暗示进行渐进式视觉问答
手机新领域用法知识
栈溢出漏洞
2021:Beyond Question-Based Biases:Assessing Multimodal Shortcut Learning in Visual Question Answeri
Ldr6028 OTG data transmission scheme for mobile devices while charging
Record the method of reading excel provided by unity and the solution to some pits encountered
CVPR2021:Separating Skills and Concepts for Novel Visual Question Answering将技巧与概念分开的新视觉问答
Fplan layout
Nacos调用微服务两个问题:1.Load balancer does not contain an instance for the service 2.Connection refused
人群模拟
2021:passage retrieval for outside knowledgevisual question answering
2021:Greedy Gradient Ensemble for Robust Visual Question Answering