我的应用程序中有 10 张图像。用户必须选择其中之一。我希望它是单击图像右上角的刻度线,而不是其他图像的刻度线。我怎样才能做到这一点?
最佳答案
您可以使用 FrameLayout 和 ImageView 并管理每个图像的选定状态。如果选择了图像,则使 imgCheck 可见,否则将其隐藏。
<FrameLayout
android:layout_width="80dp"
android:layout_height="80dp">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/img1"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="wrap_content"
android:src="@drawable/ic_checked"
android:layout_gravity="right"
android:layout_height="wrap_content"/>
</FrameLayout>
希望对你有帮助!!
关于java - Android ImageView 选择标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59837286/