3

I have created a TableLayout with a listView in it. I define the listView's size by setting it in dp. My problem is when uploading the app on a mobile with a smaller screen the listView gets to big(long) on the screen. I dont want to use a ScrollView and have a listView within it. Is there any other way to set the size of the listview which will be the same and not dependent of what mobile you are using?

Picture of the listView: http://tinypic.com/view.php?pic=2qwhoxd&s=6

<?xml version="1.0" encoding="utf-8"?>

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/bakgrunden"
android:orientation="vertical"
android:gravity="center|top"
android:stretchColumns="1"
android:weightSum="1.0" >

<TableRow>
<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" />
</TableRow> 

<TableRow
android:paddingLeft="22dp"
android:paddingRight="25dp"
android:paddingTop="15dp" >

<ListView
    android:id="@+id/latest_list"
    style="@style/CustomListView"
    android:layout_width="wrap_content"
    android:layout_height="390dp" <------- THE PROBLEM! The list gets to long for a
    android:gravity="left"/>               small-screen mobile.
</TableRow> 

</TableLayout>
Jesper Martensson
  • 1,238
  • 3
  • 18
  • 44

1 Answers1

0

Simply create a different layout for the smaller screens and allow the OS to determine which layout to load. The Android Developers site has this excellent advice: Supporting Different Screen Sizes

You could try getting fancy with layout_weight attributes or adjusting the height at run-time by determining each screen's size ( Get screen dimensions in pixels ) then calculating the appropriate height... But honestly a couple different layouts is the easiest, future-proof approach.

Community
  • 1
  • 1
Sam
  • 86,580
  • 20
  • 181
  • 179