在列表视图的列表项的底部添加阴影 [英] adding shadow on the bottom of List item of Listview
本文介绍了在列表视图的列表项的底部添加阴影的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要阴影添加到我的ListView项的底部!
我试过paddingEdageLenght但没有改变发生!
我加了圆边,但我不能添加项目下的阴影
I want to add shadow to bottom of my ListView item !! I tried paddingEdageLenght but no change happened ! I added circular edges but i can't add the shadow below the item
这是我的列表项的xml文件
this is my list item xml file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fadingEdgeLength="5sp" >
<ImageView
android:id="@+id/site_image"
android:layout_height="50dp"
android:layout_width="65dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_margin="10dp"/>
<TextView
android:id="@+id/site_name"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_toRightOf="@id/site_image"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:textSize="20sp"/>
<TextView
android:id="@+id/site_description"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_below="@id/site_name"
android:layout_marginTop="5dp"
android:layout_marginLeft="10dp"
android:layout_toRightOf="@id/site_image"
android:textSize="15sp"/>
</RelativeLayout>
这是我的ListView xml文件
and this is my ListView xml file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ListView
android:id="@+id/near_sites"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_margin="10dp"
android:fadingEdgeLength="5sp"
android:dividerHeight="10sp"
android:divider="@android:color/transparent" />
</RelativeLayout>
任何帮助吗?
推荐答案
在LIST_VIEW_ITEM,添加一个虚拟查看您的RelativeLayout后,敷他们都在垂直的LinearLayout这样
In list_view_item, add a dummy View after your RelativeLayout and wrap them all at vertical LinearLayout like this
<LinearLayout
android:orientation="vertical"
>
<RelativeLayout>
...
...
</RelativeLayout>
<View
android:id="@+id/shadow"
android:layout_width="fill_parent"
android:layout_height="3dip" <!or your needed height value/>
android:background="@drawable/shadow_drawable"
</View>
</LinearLayout>
在绘制文件夹添加新shadow_drawable.xml,并把这个吧
and at drawable folder add the new shadow_drawable.xml and put this at it
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:startColor="@color/#000000" <!black/>
android:endColor="@color/#FFFFFF" <!white/>
android:angle="90" <! angle of the gradient>
>
</gradient>
</shape>
这篇关于在列表视图的列表项的底部添加阴影的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文