How do you put a border around a ListView?

The other way to do it is to create a border resource that can then be reused, and it also means you won’t need to create extra layout to implement it.

  1. create a drawable resource

    <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
       <!-- use this for transparent -->
       <!-- <solid android:color="#00000000" /> -->
       <!-- use this for a background colour -->
       <solid android:color="#FFF" />
       <stroke android:width="2dip" android:color="#FF0000" />
    </shape>
    
  2. then set it as the listview background

    <ListView
        android:id="@id/android:list"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/border_ui" />
    

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)