安卓的LinearLayout:添加边框阴影周围的LinearLayout [英] Android LinearLayout : Add border with shadow around a linearLayout

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

问题描述

我想创建这样的LinearLayout的相同的边框为例:

在这个例子中,我们可以看到边框是不一样的一切围绕的LinearLayout。 使用XML文件绘制如何建立呢?

现在,我只能够创建一个简单的边框周围所有的LinearLayout中是这样的:

 < XML版本=1.0编码=UTF-8&GT?;
<形状的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android机器人:形状=矩形>
  <角落
      机器人:半径=1DP
      机器人:topRightRadius =0dp
      机器人:bottomRightRadius =0dp
      机器人:bottomLeftRadius =0dp/>
  <中风
      机器人:宽=1DP
      机器人:颜色=#E3E3E1/>

  [固体机器人:颜色=@色/相思/>

< /形状>
 

解决方案

试试这个..

 < XML版本=1.0编码=UTF-8&GT?;
<层列表的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android>
    <项目>
        <形机器人:形状=矩形>
            [固体机器人:颜色=#CABBBBBB/>
            <边角机器人:半径=2DP/>
        < /形状>
    < /项目>

    <项目
        机器人:左=0dp
        机器人:右=0dp
        机器人:顶部=0dp
        机器人:底部=2DP>
        <形机器人:形状=矩形>
            [固体机器人:颜色=@机器人:彩色/白/>
            <边角机器人:半径=2DP/>
        < /形状>
    < /项目>
< /层列表>
 

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

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 ?

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>

解决方案

Try this..

<?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>

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

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