如何显示在周围Android上的LinearLayout影子? [英] How to show shadow around the linearlayout in android?

查看:181
本文介绍了如何显示在周围Android上的LinearLayout影子?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么能显示出阴影我的线性布局。我想白色的圆角背景与各地的LinearLayout影子。我已经做到了这一点至今。请帮我。先谢谢了。

 <的LinearLayout
 机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_margin =10dp
机器人:背景=@ XML / rounded_rect_shape
机器人:方向=垂直
机器人:填充=10dp>
<  - 我的按钮,textviews,Imageviews去这里 - >
< / LinearLayout中>
 

和xml目录下rounded_rect_shape.xml

 < XML版本=1.0编码=UTF-8&GT?;
<形状的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
   机器人:形状=矩形>

   [固体机器人:颜色=#FFFFFF/>

   <角落
      机器人:bottomLeftRadius =3DP
      机器人:bottomRightRadius =3DP
      机器人:topLeftRadius =3DP
      机器人:topRightRadius =3DP/>
< /形状>
 

解决方案

目前在Android中没有这样的属性,展现了一层阴影。但可能的方式来做到这一点是:

  1. 添加一个普通的LinearLayout与灰色,在其中加入您的实际布局,利润率在底部和右侧等于1或2个DP

  2. 有一个9补丁图像与阴影,并将其设置为背景,以您的线性布局

How can i show shadow for my linear layout. I want white colored rounded background with shadow around the linearlayout. I have done this so far. Please help me. Thanks in advance.

<LinearLayout
 android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:background="@xml/rounded_rect_shape"
android:orientation="vertical"
android:padding="10dp">
<-- My buttons, textviews, Imageviews go here -->
</LinearLayout>

And rounded_rect_shape.xml under xml directory

 <?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
   android:shape="rectangle" >

   <solid android:color="#ffffff" />

   <corners
      android:bottomLeftRadius="3dp"
      android:bottomRightRadius="3dp"
      android:topLeftRadius="3dp"
      android:topRightRadius="3dp" />
</shape>

解决方案

There is no such attribute in Android, to show a shadow. But possible ways to do it are:

  1. Add a plain LinearLayout with grey color, over which add your actual layout, with margin at bottom and right equal to 1 or 2 dp

  2. Have a 9-patch image with a shadow and set it as the background to your Linear layout

这篇关于如何显示在周围Android上的LinearLayout影子?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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