Android LinearLayout:在 LinearLayout 周围添加带有阴影的边框 [英] Android LinearLayout : Add border with shadow around a LinearLayout

查看:89
本文介绍了Android LinearLayout:在 LinearLayout 周围添加带有阴影的边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建与示例相同的此 LinearLayout 的边框:

I would like to create the same border of this LinearLayout as the example :

在这个例子中,我们可以看到,linearLayout 周围的边框是不一样的.如何使用 XML 可绘制文件创建此文件?

In this example, we can see that the border is not the same all around the linearLayout. How can I create this using an XML drawable file?

现在,我只能像这样在 LinearLayout 周围创建一个简单的边框:

For now, I have only able to create a simple border all around the LinearLayout like this :

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
  <corners
      android:radius="1dp"
      android:topRightRadius="0dp"
      android:bottomRightRadius="0dp"
      android:bottomLeftRadius="0dp" />
  <stroke
      android:width="1dp"
      android:color="#E3E3E1" />

  <solid android:color="@color/blanc" />

</shape>

推荐答案

试试这个..

<?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="0dp"
        android:bottom="2dp">
        <shape android:shape="rectangle">
            <solid android:color="@android:color/white"/>
            <corners android:radius="2dp" />
        </shape>
    </item>
</layer-list>

这篇关于Android LinearLayout:在 LinearLayout 周围添加带有阴影的边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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