[英]how create custom shape in android jetpack compose?
I see there two ways how I would've done this:我看到有两种方法可以做到这一点:
// Usage:
@Composable
fun Somewhere() {
FolderLikeCard(
topTailContent = {
// for example, your tab will just be, without content, only for shape
Box(modifier = Modifier.size(64.dp, 12.dp))
},
mainContent = {
// main content
}
)
}
// Implementation:
@Composable
fun FolderLikeCard(
topTailContent: @Composable () -> Unit,
mainContent: @Composable () -> Unit
) {
val cornerSize = 4.dp // for example
Column {
Row {
Spacer(modifier = Modifier.weight(1f))
Box {
Canvas {
TODO("draw with help of links above tab's outline (using drawArc maybe)")
}
Box(
modifier = Modifier.padding(left = cornerSize, top = cornerSize, right = cornerSize),
content = topTailContent
)
}
}
Box {
Canvas {
TODO("draw main part outline")
}
Box(
modifier = Modifier.padding(left = cornerSize, bottom = cornerSize, right = cornerSize),
content = mainContent
)
}
}
}
+ I feel it can be refactored with help of Modifier.drawBehind
method + 我觉得它可以在
Modifier.drawBehind
方法的帮助下重构
Modifier.background(color = yourColor, shape = FolderLikeShape(tabHeight, tabWidth, ...))
method, link to the article that I read some time ago , + linked question helps , but I don't see how you can then put the content there so far, if you need it, then I hope the following commentators will help with this.Modifier.background(color = yourColor, shape = FolderLikeShape(tabHeight, tabWidth, ...))
方法中使用它, 链接到我前段时间阅读的文章, + 链接问题有帮助,但我不看看你怎么能把内容放在那里呢,如果你需要的话,那么我希望下面的评论员能帮助解决这个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.