长按时圆形按钮背景和提示

问题描述

我创建了一个ImageButton,当我对其进行长按时,其背景变为黑色。如何将其样式从

this

更改为

this one

此外,在长按时如何在按钮上添加

this brief hint

解决方法

您可以使用:

    <androidx.appcompat.widget.AppCompatImageButton
        android:background="?attr/selectableItemBackgroundBorderless"
        ../>

和:

    val imageButton : ImageButton = findViewById(R.id.imagebutton)
    ViewCompat.setTooltipText(imageButton,"Tooltip")