Android 安卓:如何产生选择效应;selectableItemBackground";在可绘制圆形图标的ImageView上?
目前,当我点击此按钮时,我有以下效果: “按钮”就是这样的图像视图:Android 安卓:如何产生选择效应;selectableItemBackground";在可绘制圆形图标的ImageView上?,android,Android,目前,当我点击此按钮时,我有以下效果: “按钮”就是这样的图像视图: <ImageView android:id="@+id/icon_link" android:layout_width="42dp" android:layout_height="42dp" android:background="?android:attr/selectableItemBackground"
<ImageView
android:id="@+id/icon_link"
android:layout_width="42dp"
android:layout_height="42dp"
android:background="?android:attr/selectableItemBackground"
android:src="@drawable/ic_added" />
因此,我的问题是:如何在具有selectableItemBackground效果的图像视图(与视图类型无关)上不使用方形选择,而是使用圆形选择,类似于:
<ImageView
android:id="@+id/icon_link"
android:layout_width="42dp"
android:layout_height="42dp"
android:background="?android:attr/selectableItemBackground"
android:src="@drawable/ic_added" />
您应该使用以下内容作为背景:
background="?attr/selectableItemBackgroundBorderless"
使用仅在API 21上可用且似乎在ImageView上不起作用的此选项。我非常确定,通过使用支持库,此选项在以前的API中可用。是的,但您应该删除
android:
前缀,因此它将使用支持库资源,而不是默认的android:background=“?attr/selectableitemsbackgroundless”