将高程添加到布局 [英] Adding elevation to layout
本文介绍了将高程添加到布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个自定义listView
,我正在使用的列表项是带有几个图像和文本的线性布局.现在,我想使此列表项有点高,就像下面的图片一样
I have a custom listView
and the list item that i am using is a linear layout with couple of images and text. Now i want to make this list item a bit elevated just like the pic below
推荐答案
对于每个列表项的背景,您可以使用xml drawable实现此效果:
For the background of each list item, you can use an xml drawable to achieve this effect:
mydrawable.xml
<?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="@color/border_shadow"/>
<corners android:radius="3dp" />
</shape>
</item>
<item
android:left="1dp"
android:right="1dp"
android:top="1dp"
android:bottom="3dp">
<shape android:shape="rectangle">
<solid android:color="@color/white"/>
<corners android:radius="3dp" />
</shape>
</item>
</layer-list>
要调整阴影大小,请在第二个item
中调整left
,right
等.在LinearLayout
中将其用作android:background="@drawable/mydrawable"
的每个项目.
To adjust the shadow sizes, tweak the left
, right
, etc. in the second item
. Use it in your LinearLayout
for each item as android:background="@drawable/mydrawable"
.
这篇关于将高程添加到布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文