She*_*Din 2 android listview shadow android-listview
我想在ListView项目的底部添加阴影!! 我尝试了paddingEdageLenght,但没有发生任何变化!我添加了圆形边缘,但我不能在项目下方添加阴影
这是我的列表项xml文件
<?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>
Run Code Online (Sandbox Code Playgroud)
这是我的ListView xml文件
<?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>
Run Code Online (Sandbox Code Playgroud)
任何帮助?
在list_view_item,然后添加一个虚拟视图,RelativeLayout并将它们全部包装在垂直方向,LinearLayout如下所示:
<LinearLayout
android:orientation="vertical">
<RelativeLayout>
...
...
</RelativeLayout>
<View
android:id="@+id/shadow"
android:layout_width="fill_parent"
android:layout_height="3dp" <!--or your needed height value-->
android:background="@drawable/shadow_drawable">
</View>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
并在drawable文件夹中添加新的shadow_drawable.xml并将其放在其中
<?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>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9723 次 |
| 最近记录: |