Android drawable layer-list右上角红点,xml布局实现,Kotlin
XML
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/pic"
android:drawable="@mipmap/ic_launcher"></item>
<item
android:id="@+id/circle"
android:width="15dp"
android:height="15dp"
android:gravity="right|top">
<shape android:shape="oval">
<solid android:color="@android:color/holo_red_light" />
<stroke
android:width="5px"
android:color="@android:color/holo_blue_dark" />
</shape>
</item>
</layer-list>
点击图片,小红点消失:
Kotlin
val iv = findViewById<ImageView>(R.id.iv)
iv.setOnClickListener { v ->
((v as ImageView).drawable as LayerDrawable).findDrawableByLayerId(
R.id.circle
).alpha = 0
}
Android layer-list:联合shape(2)-CSDN博客文章浏览阅读1.2k次。Android layer-list:联合shape(2)附录文章3简单说明了Android layer-list的用法,现在把Android layer-list联合shape做出一些特殊的应用,和附录文章3类似,先写布局文件:https://blog.csdn.net/zhangphil/article/details/51721283Android layer-list(3)-CSDN博客文章浏览阅读1.7k次。Android layer-list(3)在附录文章3、4的基础上,就Android layer-list再写一个较为复杂的应用。先写布局文件,该布局涉及到LinearLayoutCompat,关于LinearLayoutCompat参看附录文章5。布局文件activity_main.xml:https://blog.csdn.net/zhangphil/article/details/51721816