【问题标题】:Getting the Facebook Shadow Effect on Background Layout Drawable在背景布局 Drawable 上获取 Facebook 阴影效果
【发布时间】:2016-01-18 06:55:53
【问题描述】:

我想为我的 RelativeLayout 实现这种阴影效果作为背景可绘制对象:

我正在尝试在我的布局中获得指定的效果。这是描述:

答:轻描边围绕RelativeLayout

B: 阴影在布局下方,在布局的左右有轻微阴影

到目前为止我所拥有的:

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

    <item
        android:left="0dp"
        android:right="0dp"
        android:top="1dp"
        android:bottom="1dp">
        <shape android:shape="rectangle">
            <solid android:color="@android:color/white"/>
            <corners android:radius="2dp" />
        </shape>
    </item>
</layer-list>

我还应该添加什么来获得显示的结果?

【问题讨论】:

    标签: android xml android-layout drawable shadow


    【解决方案1】:

    你也可以使用CardView

    http://developer.android.com/training/material/lists-cards.html

    只需添加您自己的海拔,您就可以开始了。

    【讨论】:

    • 谢谢,但我怎样才能仅使用 XML 来实现呢?
    • 您可以将该 CardView 设置为 root,然后使用 RelativeLayout 作为内容,然后设置您想要的任何高度或重量。希望对您有所帮助。
    • 顺便说一句,它需要至少 21 的 API。我的是 15
    • 是的,这就是重点。我已经在 kitkat 上试过了,顺便说一句。还有许多材料设计库可用。你可能想看看。
    猜你喜欢
    • 2014-12-08
    • 1970-01-01
    • 2013-07-05
    • 1970-01-01
    • 2015-06-18
    • 1970-01-01
    • 2016-06-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多