据官方称Action Chips 的设计文档 https://material.io/design/components/chips.html#action-chips,我们应该能够为芯片添加进度状态。可悲的是,开发文档 https://material.io/develop/android/components/chip/根本不提这个。有谁设法弄清楚如何实现所示的效果here https://storage.googleapis.com/spec-host-backup/mio-design%2Fassets%2F1OpzE0nXqZJBm66WRVbaGvTbZEIaRAWfD%2Faction-chip-behavior-confirmation.mp4?
可以使用以下方法来实现此行为chipIcon
属性和androidx.swiperefreshlayout.widget.CircularProgressDrawable
.
xml
app:chipIconWithProgress="@{viewModel.taskIsStarting ? null : @drawable/ic_play_arrow}"
和绑定适配器
@BindingAdapter("chipIconWithProgress")
fun Chip.setChipIconWithProgress(item: Drawable?) {
chipIcon = item
?: CircularProgressDrawable(context!!).apply {
setStyle(CircularProgressDrawable.DEFAULT)
start()
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)