tags:

views:

53

answers:

2

Hi,

I want to customize list view item spaces between different items. We generally display list item with default space between them to get viewed in list.I want to customize the space difference between them so that more data can be displayed in the list within the display part at a time.

Please provide me some solution .

Thanks in adv. Praween

A: 

Vary the padding programatically?

Jim Blackler
@Jim: You should add that question as a comment, not as an answer
Macarse
It was an answer.
Jim Blackler
@Jim: It's not an answer. It's a question. See that little "?" thing on the end?
gnovice
@gnovice http://en.wikipedia.org/wiki/Rhetorical_question
Jim Blackler
A: 

Hi Praween,

When you defined a ListView, you have two components for layouts. You have :

  • The layout of the ListView itself

This layout lets you define what to display when the list is empty or filled. Please notice below the android:id="@+id/android:list" and android:id="@+id/android:empty" that allow you to decide what to display. Here an example :

<?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
         android:orientation="vertical"
         android:layout_width="fill_parent" 
         android:layout_height="fill_parent"
         android:paddingLeft="8dp"
         android:paddingRight="8dp">

     <ListView android:id="@id/android:list"
               android:layout_width="fill_parent" 
               android:layout_height="fill_parent"
               android:background="#000000"
               android:layout_weight="1"
               android:drawSelectorOnTop="false"/>

     <TextView android:id="@id/android:empty"
               android:layout_width="fill_parent" 
               android:layout_height="fill_parent"
               android:background="#FF0000"
               android:text="No data"/>
 </LinearLayout>
  • The layout of each entry

This layout will define how each entry will be display. This is what - according to me - you are insterested of. For example if you want two informations within an entry your layout for entries will look like this :

<?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:orientation="vertical">

     <TextView android:id="@+id/text1"
         android:textSize="16sp"
         android:textColor="#99FFFFFF"
         android:layout_width="fill_parent"
         android:layout_height="20px"/>

     <TextView android:id="@+id/text2"
         android:textSize="13sp"
         android:textColor="#FFFFFF"
         android:layout_width="fill_parent"
         android:layout_height="20px"/>
 </LinearLayout>

So now you just have to modified the last example layout and manage it the way you want. Hope I could help, if you need more informations do not hesitate.

Spredzy