Change android listview element height

Problem: I want to reduce row height of a single list view item. I don't know exactly it is possible or not.

Here is the codes I used

<ListView
  android:id="@+id/listView1"
  android:layout_width="match_parent"
  android:layout_height="338dp"
  android:padding="10dp"
  android:layout_y="22dp" >
</ListView>

java code

ListView list = (ListView)findViewById(R.id.listView1);

ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,arrayTest);

list.setAdapter(adapter);

Answers


As you want to reduce height of every items of ListView, you have to define Custom adapter with custom layout for your listview.

Check this:

  1. Customizing Android ListView Items with Custom ArrayAdapter
  2. Android ListView and ListActivity

If you just want to change the width of the whole width then just change the value for

android:layout_width="match_parent"

to whatever you want for instance

android:layout_width="100dp"

otherwise check out this tutorial on how to create a custom adapter and create your own layout xml for the list items


Need Your Help

Watchdog monitoring UNIX domain socket, triggering events upon specific content

sockets unix dns watchdog

I am on an embedded platform (mipsel architecture, Linux 2.6 kernel) where I need to monitor IPC between two closed-source processes (router firmware) in order to react to a certain event (dynamic IP

How to Detect / Read / Write multiple HID devices

.net delphi vb6 usb hid

I am using Temper Gold 1.1 PCsensor USB. i can connect all of them to my pc, i am able to handle Single USB device,the devices are detected as HID but when there are more than one i am lost.