gpt4 book ai didi

Android:获取芯片图标点击事件

转载 作者:太空狗 更新时间:2023-10-29 12:59:26 26 4
gpt4 key购买 nike

我使用 Material 组件芯片。在芯片中我们可以获得关闭图标点击和整个芯片点击事件。但无法找到芯片图标点击。

<com.google.android.material.chip.Chip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:textColor="@color/chip_text_color"
app:checkedIconEnabled="false"
app:chipBackgroundColor="@color/chip_background"
app:chipIcon="@drawable/ic_pencil_edit_button"
app:chipIconSize="15dp"
app:chipIconTint="@color/chip_text_color"
app:chipStrokeColor="@color/colorPrimary"
app:chipStrokeWidth="1dp"
app:closeIconTint="@color/colorYellow"
app:iconStartPadding="@dimen/spacing_tiny" />

Chip image

最佳答案

如果您的 Chip View 有 id chip:

findViewById<Chip>(R.id.chip).setOnTouchListener { v, event ->
if (v is Chip) {
if (event.x <= v.totalPaddingLeft) {
//HANDLE CLICK TO THE ICON
}
return@setOnTouchListener true
}
return@setOnTouchListener false
}

关于Android:获取芯片图标点击事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56730974/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com