【问题标题】:How to make shadow in layer-list?如何在图层列表中制作阴影?
【发布时间】:2015-09-17 08:28:25
【问题描述】:

问题如下:我需要在应用小部件中制作一些这样的操作栏:

为此,我使用带有形状的图层列表。

<?xml version="1.0" encoding="utf-8"?>

<!-- Bottom 2dp Shadow -->

<item>
    <shape  android:shape="rectangle">
        <solid android:color="#027668"/>
        <corners android:radius="12dp"/>
    </shape>
</item>

<!-- White Top color -->
<item android:bottom="4dp">
    <shape  android:shape="rectangle">
        <solid android:color="#20a18b" />
        <corners android:radius="7dp" />
    </shape>

</item>

我得到了一些看法:

但是,我不能像在这篇文章的第一张图片上那样在阴影周围做一些事情。

怎么做?

【问题讨论】:

  • 使用 9 补丁可绘制
  • 请检查我的答案吗?
  • 不,它没有解决我的问题

标签: android android-linearlayout material-design layer-list android-shape


【解决方案1】:

给你:

将你的可绘制背景更改为:

<?xml version="1.0" encoding="utf-8"?><!-- Bottom 2dp Shadow -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="rectangle">
            <solid android:color="#027668" />
            <corners android:radius="12dp" />
        </shape>
    </item>

    <!-- White Top color -->
    <item android:bottom="4dp">
        <shape android:shape="rectangle">
            <solid android:color="#20a18b" />
            <corners android:radius="7dp" />
            <stroke
                android:width="2dp"
                android:color="#027668" />
        </shape>

    </item>
</layer-list>

结果

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-02
    • 2012-04-25
    • 1970-01-01
    • 1970-01-01
    • 2018-12-16
    相关资源
    最近更新 更多