#Android给ListView加边框
16lz
2021-01-26
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。
更多相关文章
- INSTALL_FAILED_TEST_ONLY的原因
- Flutter-基础组件2
- Android(安卓)动画之集合动画AnimatorSet
- android系统属性获取及设置
- View点击涟漪效果
- android:targetSdkVersion 属性导致程序问题
- android学习中--弹球游戏
- android style中出现自定义属性时的写法
- Applying Styles and Themes - 应用Style和Theme - Android官方