【问题标题】:How to add a drop shadow to a Rectangular Shape in Android如何在 Android 中为矩形形状添加阴影
【发布时间】:2015-06-12 08:15:51
【问题描述】:

我正在开发一个 Android 应用程序,我需要在其中使用一个应该有一个 drop_shadow 的矩形形状。我设计了一个矩形,但不知何故我无法在(右侧和左侧)上添加阴影。 P.S.:这个矩形是作为背景属性添加的。

如果此类问题已得到解答,请在此处提供链接。

提前谢谢你!!!!

代码:

    <?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#ffffff" />
    <stroke
        android:width="1dp"
        android:color="#000000" />
    <corners
        android:radius="10dp"   >
    </corners>

</shape>

【问题讨论】:

标签: android android-layout shadow dropshadow roundedcorners-dropshadow


【解决方案1】:

试试这个:

    <?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="1dp"
        android:top="0dp"
        android:bottom="2dp">

        <shape android:shape="rectangle">
            <solid android:color="@android:color/white"/>
            <corners android:radius="1dp" />
        </shape>
   </item>
</layer-list>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-14
    • 2013-04-30
    相关资源
    最近更新 更多