【问题标题】:I want to give radius to shadow shown inside a layout in android我想给 android 布局内显示的阴影半径
【发布时间】:2022-01-04 04:41:11
【问题描述】:

我想在卡片视图中添加阴影并得到如下所示的解决方案:

但我也想为阴影赋予半径,这是我无法做到的,

这是我的代码:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

    <item>
        <shape android:shape="rectangle">
            <solid android:color="@color/yellow"/>
            <corners android:radius="@dimen/_20sdp"/>
        </shape>

    </item>
    <item>
        <shape android:shape="rectangle">
            <gradient
                android:angle="180"
                android:centerColor="#00FF0000"
                android:centerX="0.97"
                android:centerY="0.5"
                android:endColor="#5C000000"
                android:startColor="#00FF0000" />
        </shape>
    </item>
    <item>
        <shape android:shape="rectangle">
            <gradient
                android:angle="270"
                android:centerColor="#00FF0000"
                android:centerY="0.1"
                android:endColor="#00FF0000"
                android:startColor="#6B000000" />
            <corners android:radius="@dimen/_20sdp" />
        </shape>
    </item>
</layer-list>

谁能帮我解决这个问题?

提前致谢。

【问题讨论】:

    标签: android kotlin


    【解决方案1】:

    将图像像阴影一样转移到您想要的顶部布局。 或者 创建渐变可绘制。 试试下面的方法

    <?xml version="1.0" encoding="UTF-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
    
        <gradient
            android:angle="90"
            android:centerColor="#555994"
            android:endColor="#b5b6d2"
            android:startColor="#555994"
            android:type="linear" />
    
        <corners 
            android:radius="0dp"/>
    
    </shape>
    

    【讨论】:

      猜你喜欢
      • 2021-05-21
      • 2021-12-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多