2012-06-17 3 views
3

ListView를 포함하는 TableLayout을 만들었습니다. dp로 설정하여 listView의 크기를 정의합니다. 내 문제는 작은 화면으로 모바일에 응용 프로그램을 업로드하면 listView가 화면에서 크게 (길게) 표시됩니다. ScrollView를 사용하고 그 안에 listView를 갖고 싶지 않습니다. listview의 크기를 설정하는 다른 방법이 있습니까? 사용하는 모바일에 따라 다르며 동일하지 않습니까? 목록보기의Android에서 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> 

답변

0

은 단순히 작은 화면에 다른 레이아웃을 생성하고 OS가로드 할 레이아웃을 결정할 수 있습니다. 안드로이드 개발자 사이트는이 훌륭한 조언이 있습니다 Supporting Different Screen Sizes

당신은 몇 정직 layout_weight 속성을 공상 얻거나 다음 적절한 높이를 계산하는 각 화면의 크기 ( Get screen dimensions in pixels)을 결정하여 실행시 높이를 조정 ...하지만 시도 할 수

서로 다른 레이아웃이 가장 쉽고 미래 지향적 인 접근 방법입니다.

관련 문제