LocalDensity
时间: 2024-01-02 12:04:12 浏览: 49
LocalDensity是Compose框架中的一个类,用于获取当前系统的density和fontScale参数。通过LocalDensity.current可以获取到当前的Density对象,从而可以自由控制应用内文字的显示大小。\[1\]此外,LocalDensity还可以通过CompositionLocalProvider特性来细腻度地控制修改后的密度生效范围,而不会影响全局。\[2\]在适配中,可以使用CompositionLocal包装的全局变量,局部可以直接获取值,并且更改值后只在CompositionLocalProvider提供的作用域内有效,出了该作用域失效,不会影响其他调用处。\[3\]
#### 引用[.reference_title]
- *1* *2* [Compose (13) - 屏幕适配](https://blog.csdn.net/HugMua/article/details/130328208)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down28v1,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [Compose - 隐式传参 CompositionLocal](https://blog.csdn.net/HugMua/article/details/130049635)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down28v1,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
相关推荐
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pptx](https://img-home.csdnimg.cn/images/20210720083543.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)