无法理解图层列表 [英] Unable to understand layer-list
问题描述
<?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
它如何给我一个环形?
How is it giving me a ring shape?
layer-list的工作原理以及顶部,右侧的作用是什么?
How layer-list works and What do top, right, bottom and left attributes of item tag do?
不能只用环形形状吗?为什么要用椭圆形做成环形形状呢? / p>
Cant we just use ring shape ?Why go for oval shape to make ring shape?
推荐答案
层列表是可绘制的,称为带有的其他可绘制对象的序列< item>
标记。
从您的问题中,第一个< item>
是内部椭圆形&上,下,右&左边是赋予该项目的插图(与填充相同)。尝试提供宽度&首先,您可以看到椭圆形的内部形状,外部椭圆形具有4dp填充。
A layer list is drawable, called sequence of other drawables with <item>
tag.
Here from your question the first <item>
is inner oval shape & top, bottom, right & left are insets given to that item (just same as padding). Try to give width & height to first you can see inner oval shape with 4dp padding from outer oval.
有关可绘制图层的详细信息,请参见此链接 http://developer.android.com/reference/android/graphics/drawable/LayerDrawable.html
Refer to this link for more detail about layer drawable http://developer.android.com/reference/android/graphics/drawable/LayerDrawable.html
是的,您可以使用环形形状像这样绘制圆环:
Yes you can use ring shape to draw a ring like:
<?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>
这篇关于无法理解图层列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!