android中listview项的边框

前端之家收集整理的这篇文章主要介绍了android中listview项的边框前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想设置Edittext的边框和listview的项目,如图所示:

我的xml代码如下:

  1. <LinearLayout
  2. android:background="#BDD6E0"
  3. android:layout_height="wrap_content"
  4. android:layout_width="match_parent"
  5. android:orientation="vertical" >
  6.  
  7. </LinearLayout>
  8.  
  9. <LinearLayout
  10. android:background="#BDD6E0"
  11. android:layout_height="wrap_content"
  12. android:layout_width="match_parent"
  13. android:orientation="vertical" >
  14.  
  15. <TextView
  16. android:id="@+id/textView1"
  17. android:layout_width="match_parent"
  18. android:layout_height="wrap_content"
  19. android:layout_weight="1"
  20. android:text="Search"
  21. android:textColor="#000000"
  22. android:background="#FFFFFF"
  23. android:textAppearance="?android:attr/textAppearanceLarge" />
  24.  
  25. <EditText
  26. android:id="@+id/search_pat_edit"
  27. android:layout_width="match_parent"
  28. android:layout_height="wrap_content"
  29. android:singleLine="true"
  30. android:textColor="#000000"
  31. android:layout_weight="4">
  32.  
  33. </EditText>
  34.  
  35. </LinearLayout>
  36.  
  37. <LinearLayout
  38. android:background="#c0c0c0"
  39. android:layout_height="0dp"
  40. android:layout_width="match_parent"
  41. android:layout_weight="6" >
  42.  
  43. <ListView
  44. android:id="@+id/listView1"
  45. android:layout_width="match_parent"
  46. android:layout_height="wrap_content"
  47. android:background="#FFFFFF"
  48. android:layout_weight="1" >
  49. </ListView>
  50.  
  51. </LinearLayout>
  52.  
  53. </LinearLayout>

如何在listview项目中绘制边框?

解决方法

列表视图的背景
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <shape xmlns:android="http://schemas.android.com/apk/res/android"
  3. android:shape="rectangle">
  4. <stroke android:width="1dip" android:color="@color/edt_focused" />
  5. </shape>

并将属性添加到listview

  1. android:divider="@drawable/list_divider" android:dividerHeight="1px"

猜你在找的Android相关文章