比如我有一个 composable 的一个组件,其中更要包含几个类似 SwitchPrefeence 、TextPreference 这样的控件。
难道非得自己一个个从 Text\Icon 去 Compose 么?没有已经造好的轮子么?
1 ho121 2023-04-25 19:19:45 +08:00 via Android 换个思路,不如造个这样的轮子,说不定会火 |
![]() | 2 maokg 2023-04-25 19:38:17 +08:00 看成了 sharedpreference |
![]() | 3 Mystery0 2023-04-25 19:57:12 +08:00 |
![]() | 4 yufz 2023-04-25 20:39:58 +08:00 ``` ListItem( headlineText = { Text("Hello") }, supportingText = { Text("Hello World") }, leadingCOntent= { Icon(imageVector = Icons.Filled.Settings, cOntentDescription= "") }, trailingCOntent= { Switch(checked = true, OnCheckedChange= {}) } ) ``` 如果只是要个简单的 UI ,可以试下 androidx.compose.material3 下的 ListItem ![]() |
![]() | 5 300 2023-04-25 20:42:59 +08:00 via Android 现在都是让 chatgpt 直接给了 :doge |
6 yor1g 2023-04-25 21:36:02 +08:00 不就是几个 Card 加个点击事件 ... |
![]() | 7 zhwguest OP 谢谢各位。其实自己来 compose 不是不可以,但是做控件的都知道,里面有很多小细节,不一定跟 native 的控件一致。另外就是有点想不通为什么不提供。 既然没有那就慢慢造吧。 |
![]() | 8 fromzero 2023-04-29 17:44:35 +08:00 compose 默认只提供了 material design 的控件 ,https://m3.material.io/components 因为 SwitchPreference 不在 material design 的设计规范里 |