1. 在res/drawable/目录下新建 mygradient.xml
2. 在目标listview下方添加一个view,view的背景使用我们新建的 mygradient.xml,如果在listview和view的外围包裹有linearlayout,请将linearlayout的orientation设置为vertical!
=====================================================================
=====================================================================
或者使用下段代码:
哈哈...第一种方案是当时为了实现效果,google后瞎折腾出来的,方案二则是在翻阅android source code时意外的发现,实在是很方便啊!
效果图如下:
1. 在res/drawable/目录下新建 mygradient.xml
- <?xml version="1.0" encoding="utf-8"?>
- <shape xmlns:android="http://schemas.android.com/apk/res/android"
- android:shape="rectangle" >
- <gradient
- android:startColor="#282828"
- android:centerColor="#808080"
- android:endColor="#282828"
- android:angle="0" />
- </shape>
2. 在目标listview下方添加一个view,view的背景使用我们新建的 mygradient.xml,如果在listview和view的外围包裹有linearlayout,请将linearlayout的orientation设置为vertical!
- <ListView android:id="@+id/lvProvider"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content" />
- <View android:id="@+id/divider"
- android:layout_width="fill_parent"
- android:layout_height="1dip"
- android:background="@drawable/mygradient" />
=====================================================================
=====================================================================
或者使用下段代码:
- <View
- android:layout_width="fill_parent"
- android:layout_height="1px"
- android:background="?android:attr/listDivider"
- />
哈哈...第一种方案是当时为了实现效果,google后瞎折腾出来的,方案二则是在翻阅android source code时意外的发现,实在是很方便啊!
效果图如下:
- <?xml version="1.0" encoding="utf-8"?>
- <shape xmlns:android="http://schemas.android.com/apk/res/android"
- android:shape="rectangle" >
- <gradient
- android:startColor="#282828"
- android:centerColor="#808080"
- android:endColor="#282828"
- android:angle="0" />
- </shape>
2. 在目标listview下方添加一个view,view的背景使用我们新建的 mygradient.xml,如果在listview和view的外围包裹有linearlayout,请将linearlayout的orientation设置为vertical!
- <ListView android:id="@+id/lvProvider"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content" />
- <View android:id="@+id/divider"
- android:layout_width="fill_parent"
- android:layout_height="1dip"
- android:background="@drawable/mygradient" />
=====================================================================
=====================================================================
或者使用下段代码:
- <View
- android:layout_width="fill_parent"
- android:layout_height="1px"
- android:background="?android:attr/listDivider"
- />
哈哈...第一种方案是当时为了实现效果,google后瞎折腾出来的,方案二则是在翻阅android source code时意外的发现,实在是很方便啊!
效果图如下: