Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting the size of a listview

How to understand the number of rows that will be shown in the screen for that listview? What I try to tell is as you see the columns are leveled which is what I don't want. I want to know how many rows can user's phone see, which will make my time table list to fit it.

Also how can I remove the bar on top? I don't know what it is called, so couldn't search for it either.

MyApp

like image 315
Onur Avatar asked Oct 22 '22 15:10

Onur


1 Answers

For the first part, there might be some other conventional way of doing it, but this is how I would approach it.

First, find the height of the screen using

Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int height = size.y;

Then find the number of entries in your list by using mListView.getCount(). Divide the total height available with the number of rows to get the height of each row.

For the second part of your question,

It is called the TitleBar and you can hide it by adding the following code in your AndroidManifest.xml file :

<activity android:name=".ActivityName"
    android:label="@string/app_name"
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
</activity>
like image 152
Swayam Avatar answered Oct 31 '22 12:10

Swayam