2
我已經在這裏搜索了很多,並且已經實現了通用解決方案。我想是這樣的(紅色邊框列表視圖列項):在ListView的每一行放置一個邊框
我所得到的是這個(紅色邊框僅在頂部可見):
這裏是實現:
ListView.xml
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/gray"
android:paddingTop="1dp" >
<android.support.v4.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swipe_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingRight="17dp"
android:paddingTop="5dp"
android:paddingLeft="17dp">
<ListView
android:id="@+id/lv_feeds"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="@android:color/transparent"
android:dividerHeight="5.0sp"
android:scrollbars="none">
</ListView>
</RelativeLayout>
</android.support.v4.widget.SwipeRefreshLayout>
</FrameLayout>
row_listview.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/border">
.....
</LinearLayout>
border.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/white" />
<stroke android:width="12dp" android:color="@color/app_red"/>
</shape>
謝謝你的工作。你可以通過添加'android:paddingBottom =「5dp」'來更新你的答案,它將邊界添加到行的底部。 – stud91 2015-02-11 05:42:40
不適合我 – Amalo 2017-06-20 12:09:56