0

我想在drawables中添加阴影,以便在任何android图标(导航栏、自定义视图、按钮)上使用它们。然后应该得到这样的东西。尝试使用 Ninepatch 和图层列表或仅使用 png。它可以工作,但是有一个问题:由于阴影,drawable的填充增加了,结果主图变小了。例如,在选择器中使用这样的图层列表和其他图像变得不可能。有什么办法呢?

4

1 回答 1

0

好的,我只是使用阴影 png 位图作为矢量图像的背景,如下所示:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/ic_vector_active_with_sunshine" android:state_checked="true" />
    <item android:drawable="@drawable/ic_vector_inactive" android:state_checked="false" />
</selector>

哪里ic_vector_active_with_sunshine

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/drop_shadow" />
    <item android:drawable="@drawable/ic_vector" />
</layer-list>
于 2021-07-17T18:08:53.117 回答