Android drawable layer-list右上角红点,xml布局实现,Kotlin

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

相关推荐
Cao_Shixin攻城狮3 小时前
Flutter运行Android项目时显示java版本不兼容(Unsupported class file major version 65)的处理
android·java·flutter
呼啦啦呼啦啦啦啦啦啦6 小时前
利用pdfjs实现的pdf预览简单demo(包含翻页功能)
android·javascript·pdf
idjl8 小时前
Mysql测试题
android·adb
游戏开发爱好者810 小时前
iOS App 电池消耗管理与优化 提升用户体验的完整指南
android·ios·小程序·https·uni-app·iphone·webview
人生游戏牛马NPC1号11 小时前
学习 Flutter (四):玩安卓项目实战 - 中
android·学习·flutter
星辰也为你祝福h12 小时前
Android原生Dialog
android
梁同学与Android13 小时前
Android ---【CPU优化】需要优化的原因及优化的地方
android
Misha韩14 小时前
React Native 基础tabBar和自定义tabBar - bottom-tabs
android·react native
iHero14 小时前
【Nextcloud】在 Ubuntu 22.04.3 LTS 上的 Nextcloud Hub 10 (31.0.2) 后台任务cron 的优化
android·linux·ubuntu·nextcloud
yuanlaile18 小时前
Flutter Android打包学习指南
android·flutter·flutter打包·flutter android