Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/193.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 安卓:如何产生选择效应;selectableItemBackground";在可绘制圆形图标的ImageView上?_Android - Fatal编程技术网

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”