San*_*inh 9 android android-layout android-button android-jetpack android-jetpack-compose
我需要使用 Jetpack Compose 在 Button 中添加带圆角的边框
喜欢 :
Pra*_*ale 56
只需使用修饰符即可:
modifier = Modifier.border( width = 2.dp,
color = Color.Red,
shape = RoundedCornerShape(5.dp))
Run Code Online (Sandbox Code Playgroud)
Gab*_*tti 28
随着1.0.x
与圆角边框实现了按钮,你可以使用OutlinedButton
在应用组件shape
参数RoundedCornerShape
:
OutlinedButton(
onClick = { },
border = BorderStroke(1.dp, Color.Red),
shape = RoundedCornerShape(50), // = 50% percent
//or shape = CircleShape
colors = ButtonDefaults.outlinedButtonColors(contentColor = Color.Red)
){
Text( text = "Save" )
}
Run Code Online (Sandbox Code Playgroud)
RJn*_*Jnr 23
使用剪辑修改器,此外您还可以选择特定的角来弯曲
modifier = Modifier.clip(RoundedCornerShape(15.dp, 15.dp, 0.dp, 0.dp))
Run Code Online (Sandbox Code Playgroud)
小智 7
这是该图像中的按钮:
Button(
onClick = {},
shape = RoundedCornerShape(23.dp),
border = BorderStroke(3.dp, Color.Red),
colors = ButtonDefaults.buttonColors(contentColor = Color.Red, backgroundColor = Color.White)
) {
Text(
text = "Save",
fontSize = 17.sp,
modifier = Modifier.padding(horizontal = 30.dp, vertical = 6.dp)
)
}
Run Code Online (Sandbox Code Playgroud)
小智 6
尝试这个
Box(
modifier = Modifier
.fillMaxWidth()
.height(40.dp)
.padding(4.dp)
.clip(RoundedCornerShape(8.dp))
.background(Color.White)
.border(
1.dp,
Color.RED,
shape = RoundedCornerShape(8.dp),
)
) {
Text(
modifier = Modifier.align(Alignment.Center),
text = "Save",
color = Color.RED,
style = MaterialTheme.typography.h6
)
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
7908 次 |
最近记录: |