Android给ListView加边框

新建一个drawable的xml文件:leftlist_bg.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android">    <solid android:color="@color/leftlist_item_normal"/>    <stroke android:width="1px" android:color="@color/split_line"/></shape>

然后在listview上应用

<ListView    android:id="@+id/left_nav"    android:layout_width="300dp"    android:layout_height="match_parent"    android:paddingRight="1px"    android:layout_marginBottom="40dp"    android:background="@drawable/leftlist_bg></ListView>

注意:paddingRight="1px",如果不设置这个属性的话,listview有item的地方是没有边框的。

item的layout_widht=““match_parent"会盖住边框。所以要paddingRight 1个px。

更多相关文章

  1. INSTALL_FAILED_TEST_ONLY的原因
  2. Flutter-基础组件2
  3. Android(安卓)动画之集合动画AnimatorSet
  4. android系统属性获取及设置
  5. View点击涟漪效果
  6. android:targetSdkVersion 属性导致程序问题
  7. android学习中--弹球游戏
  8. android style中出现自定义属性时的写法
  9. Applying Styles and Themes - 应用Style和Theme - Android官方

随机推荐

  1. 如何开始我们的 DevOps 转型之旅?
  2. Flink计算PV,UV的案例及问题分析
  3. 轻量化 Jenkins 最佳实践
  4. 浪尖刷过leetcode的题
  5. 计算文本算式,其实很简单
  6. Flink通过异步IO实现redis维表join
  7. 最简单的全年个税计算模板,拿走不谢
  8. 《数据持久化与鸿蒙的分布式数据管理能力
  9. 移动办公服务的未来之路
  10. 新冠肺炎:新增确诊和治愈病例走势图