无法理解图层列表

时间:2016-03-15 06:43:06

标签: android layer-list android-shape android-shapedrawable

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:top="4dp"
        android:right="4dp"
        android:bottom="4dp"
        android:left="4dp">
        <shape
            android:shape="oval">
            <solid android:color="#ff0000" />
        </shape>
    </item>
    <item>
        <shape
            android:shape="oval">
            <stroke android:width="2dp"
                android:color="#ff0000"/>
        </shape>
    </item>
</layer-list>

取自这里:

https://stackoverflow.com/a/36003935/6007737

  

它是如何给我一个戒指形状的?

图层列表的工作原理以及item标记的top,right,bottom和left属性有哪些作用?

  

我们只能使用戒指形状吗?为什么选择椭圆形来制作戒指形状?

1 个答案:

答案 0 :(得分:0)

图层列表是可绘制的,称为带有<item>标记的其他drawable的序列。 在您的问题中,第一个<item>是内部椭圆形&amp;顶部,底部,右侧和右侧left是给予该项目的插入(与填充相同)。尝试给出宽度和宽度首先你可以看到内部椭圆形状,外椭圆形有4dp填充物。

有关图层可绘制http://developer.android.com/reference/android/graphics/drawable/LayerDrawable.html

的详细信息,请参阅此链接

是的,您可以使用戒指形状绘制如下的戒指:

<?xml version="1.0" encoding="utf-8"?>
<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="ring"
    android:innerRadius="15dp"
    android:thickness="10dp"
    android:useLevel="false">
    <solid android:color="#ff0000" />

</shape>
相关问题