我已经在这里搜索了很多,并实现了通用的解决方案。我想要的是这样的(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>

行列表视图.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>

边界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>

最佳答案

为线性布局提供一些左右填充:

<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"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingBottom="5dp">
    .....
  </LinearLayout>

09-25 22:58
查看更多