这是我要构建的所需可绘制对象。
问题:
据我所知,层列表的大小取决于其中的最后一项。但是,如果我在标签android:drawable
中使用<item>
,则图层列表将被裁剪为可绘制的大小并不重要。
这是我的swipe_close.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape
android:innerRadius="0dp"
android:shape="ring"
android:thickness="34dp"
android:useLevel="false">
<solid android:color="#ffffff" />
</shape>
</item>
<item android:drawable="@drawable/ic_close_swipe" />
<item>
<shape
android:innerRadius="34dp"
android:shape="ring"
android:thickness="10dp"
android:useLevel="false">
<solid android:color="#E6E6E6" />
</shape>
</item>
</layer-list>
还有ic_close_swipe.xml
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="39dp"
android:height="39dp"
android:viewportWidth="39"
android:viewportHeight="39">
<path
android:pathData="M37.7269,5.2568C38.5079,4.4757 38.5079,3.2094 37.7269,2.4283L36.5711,1.2726C35.7901,0.4916 34.5238,0.4916 33.7427,1.2726L20.7758,14.2395C19.9947,15.0206 18.7284,15.0206 17.9473,14.2395L4.9804,1.2726C4.1994,0.4916 2.933,0.4916 2.152,1.2726L0.9962,2.4283C0.2152,3.2094 0.2152,4.4757 0.9962,5.2568L13.9632,18.2237C14.7442,19.0048 14.7442,20.2711 13.9632,21.0521L0.9962,34.0191C0.2152,34.8001 0.2152,36.0665 0.9962,36.8475L2.152,38.0032C2.933,38.7843 4.1994,38.7843 4.9804,38.0032L17.9473,25.0363C18.7284,24.2553 19.9947,24.2553 20.7758,25.0363L33.7427,38.0032C34.5238,38.7843 35.7901,38.7843 36.5711,38.0032L37.7269,36.8475C38.5079,36.0665 38.5079,34.8001 37.7269,34.0191L24.7599,21.0521C23.9789,20.2711 23.9789,19.0048 24.7599,18.2237L37.7269,5.2568Z"
android:fillColor="#C4C4C4"/>
</vector>
答案 0 :(得分:1)
我建议如下更改swipe_close.xml
。
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape
android:innerRadius="0dp"
android:shape="ring"
android:thickness="34dp"
android:useLevel="false">
<solid android:color="#ffffff" />
</shape>
</item>
<item
android:bottom="25dp"
android:drawable="@drawable/ic_close_swipe"
android:left="25dp"
android:right="25dp"
android:top="25dp" />
<item>
<shape
android:shape="ring"
android:thickness="10dp"
android:useLevel="false">
<solid android:color="#E6E6E6" />
</shape>
</item>
</layer-list>
希望有帮助!