Android为用户点击添加圈子

时间:2019-01-15 17:06:40

标签: android image

我在android中有一个可点击的图像,如下所示:

<ImageView
                android:id="@+id/theImage"
                android:layout_width="300dp"
                android:layout_height="wrap_content"
                android:adjustViewBounds="true"
                android:clickable="true"
                android:layout_gravity="center"
                android:scaleType="fitXY" />

现在,我想在用户单击图像时做出某种手势。我希望用户看到他单击了图像,所以我想做类似的事情,每次用户单击图像时,用户单击的地方都会出现一个红色的小圆圈,然后消失。

有可能吗?

1 个答案:

答案 0 :(得分:0)

最好使用ImageButton代替imageView并设置背景属性?attr/selectableItemBackground

<ImageButton
        android:id="@+id/theImage"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="?attr/selectableItemBackground"
        android:src="@mipmap/theImage_icon"
        />
相关问题