Red dot in the upper right corner of Android drawable layer-list, xml layout implementation, Kotlin

Red dot in the upper right corner of Android drawable layer-list, xml layout implementation, Kotlin

 

<?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>

 

e6538e2625a84a6da042f501ca0a78dd.png

 

Click on the picture and the little red dot disappears:

        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: Joint shape (2) - CSDN Blog The article has been viewed 1.2k times.Android layer-list: Combined with shape (2) Appendix article 3 briefly explains the usage of Android layer-list. Now combine Android layer-list with shape to make some special applications. Similar to appendix article 3, write the layout file first. :https://blog.csdn.net/zhangphil/article/details/51721283Android layer-list (3)-CSDN Blog The article has been viewed 1.7k times.Android layer-list (3) Based on appendix articles 3 and 4, write a more complex application based on Android layer-list. First write the layout file, which involves LinearLayoutCompat. For more information about LinearLayoutCompat, see Appendix Article 5. Layout file activity_main.xml:https://blog.csdn.net/zhangphil/article/details/51721816

 

 

Guess you like

Origin blog.csdn.net/zhangphil/article/details/134689524