#Android给ListView加边框

#Android给ListView加边框android

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

<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上应用orm

<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的地方是没有边框的。xml

item的layout_widht=""match_parent"会盖住边框。因此要paddingRight 1个px。it

相关文章
相关标签/搜索