Android:带有圆形阴影的布局 [英] Android : Layout with Rounded drop shadow

查看:47
本文介绍了Android:带有圆形阴影的布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要形状在布局的背景中,如下图所示.我尝试了一些东西,如下所示.

I want shape in the background of the layout like given below picture. I have tried something , Which is given below.

borders.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!--Layer 0-->
<!--Layer 1-->
<!--Layer 2-->
<!--Layer 3-->
<!--Layer 4 (content background)-->

    <!-- dropshadow -->
    <item>
        <shape>
            <solid android:color="#10CCCCCC" />
            <padding android:top="1dp" android:right="1dp" android:bottom="1dp" android:left="1dp" />
        </shape>
    </item>

    <item>
        <shape>
            <solid android:color="#20CCCCCC" />
           <padding android:top="1dp" android:right="1dp" android:bottom="1dp" android:left="1dp" />
        </shape>
    </item>

    <item>
        <shape>
            <solid android:color="#40CCCCCC" />
            <padding android:top="1dp" android:right="1dp" android:bottom="1dp" android:left="1dp" />
        </shape>
    </item>

    <item>
        <shape>
            <solid android:color="#50CCCCCC" />
            <padding android:top="1dp" android:right="1dp" android:bottom="1dp" android:left="1dp" />
        </shape>
    </item>

    <item>
        <shape>
            <solid android:color="#60CCCCCC" />
            <padding android:top="1dp" android:right="1dp" android:bottom="1dp" android:left="1dp" />
        </shape>
    </item>

    <!-- content background -->
    <item>
        <shape>
            <solid android:color="#ffffff" />
        </shape>
    </item>
</layer-list>

并且布局设置为

android:background="@drawable/borders"

通过这个实现,我得到了这样的

如何获得如下图所示的圆角阴影?

How can I get the drop shadow with rounded corners like below image?

推荐答案

你应该给形状添加角":

you should add "corners" to the shape:

 <?xml version="1.0" encoding="UTF-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android"> 
<solid android:color="#ffffffff"/>    

<stroke android:width="3dp"
        android:color="#ff000000"
        />

<padding android:left="1dp"
         android:top="1dp"
         android:right="1dp"
         android:bottom="1dp"
         /> 

<corners android:radius="7dp"/> 

这篇关于Android:带有圆形阴影的布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆