HarmonyOS鸿蒙Next中按钮如何设置不要背景色,任何状态下都不要背景色
HarmonyOS鸿蒙Next中按钮如何设置不要背景色,任何状态下都不要背景色
@Extend(Button)
function customStateStyle() {
.stateStyles({
clicked:{
.backgroundColor(Color.Transparent)
},
focused:{
.backgroundColor(Color.Transparent)
},
normal:{
.backgroundColor(Color.Transparent)
},
pressed:{
.backgroundColor(Color.Transparent)
},
selected:{
.backgroundColor(Color.Transparent)
},
disabled:{
.backgroundColor(Color.Transparent)
},
})
}
为什么这样设置后,还是在按住按钮时有点灰的颜色
更多关于HarmonyOS鸿蒙Next中按钮如何设置不要背景色,任何状态下都不要背景色的实战教程也可以访问 https://www.itying.com/category-93-b0.html
3 回复
按道理来说设置了pressed就可以了,不晓得哪里抽风了不行,实测必须要设置stateEffect(false)才可以没有任何效果
楼主有啥特殊需求吗,既然这样为啥不直接用Text呢
更多关于HarmonyOS鸿蒙Next中按钮如何设置不要背景色,任何状态下都不要背景色的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html
明天试试,需要按钮的禁用状态的UI效果,
在HarmonyOS鸿蒙Next中,若需设置按钮无背景色,可在XML布局文件中使用Button
组件,并设置background
属性为@null
。例如:
<Button android:background="@null" />
这将确保按钮在任何状态下均无背景色。