Hi,
I want to add a border in a listview with code rather than on the xml, I have searched google but to no avail, can anyone point me in the right direction?
Thanks in advance
Hi,
I want to add a border in a listview with code rather than on the xml, I have searched google but to no avail, can anyone point me in the right direction?
Thanks in advance
Hai Friend, Refer this Java code
In Android divider is nothing but separator or border and it has two properties.To set the divider between the List Items to "nothing", you have two options. The first is in Java,
ListView x = (ListView)findViewById(R.id.ListView01);
x.setDivider(null);
x.setDividerHeight(0);
The alternative is to set it in XML, but in this case its more of a hack than the above of turning it ‘off’.
<ListView
android:id="@+id/ListView01"
android:background="#ffffff"
android:dividerHeight="0px"
android:divider="#ffffff" />
Even though the dividerHeight is set to 0 (0px, 0dp, whatever, the results were the same), a black line was still visible. The best solution is to set the colour (the divider value) to the same as your background. Using a gradient or image as the background?
Hi
There is one way I have used, but that can be done in XML only.
android:background="#ffffff"
android:divider="#ffcccccc"
android:dividerHeight="1dip"/>
What I am doing is, putting listview in a LinearLayout. Background color of the list is different than that of layout. There is a margin set for layout. Hence the distance between list and layout will appear like a border for the listview. Hope this helps.