2013-01-15 2 views
0

레이아웃 파일을 만들었습니다. 거기에 다른 레이아웃이 포함되어 있습니다. 목록보기가 하나 있습니다. 나는 그것에 고침 높이를주고있다. 내 화면에서 잘 작동하지만 다른 화면 크기에 사용하는 경우 전체 화면에 표시되지 않습니다. 모든 크기의 장치에서 어떻게 작동 할 수 있습니까? 코드는 아래와 같습니다. layout_height = "270dp을"특정 길이의 안드로이드리스트보기 크기 고정

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:tools="http://schemas.android.com/tools" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
    android:background="@drawable/bg" > 

    <include 
     android:id="@+id/mainScreenHeader" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     layout="@layout/main_screen_header" /> 


    <include 
     android:id="@+id/mainScreenListHeader" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/mainScreenHeader" 
     layout="@layout/main_screen_list_header" > 
    </include> 

    <ListView 
     android:id="@+id/list" 
     android:layout_width="fill_parent" 
     android:layout_height="270dp" 
     android:layout_below="@+id/mainScreenListHeader" 
     android:cacheColorHint="#00000000" 
     android:drawSelectorOnTop="false" /> 

    <include 
     android:id="@+id/mainScreenFilterClient" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/list" 
     android:layout_marginTop="10dp" 
     layout="@layout/main_screen_filter_client" > 
    </include> 

    <include 
     android:id="@+id/footer" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/mainScreenFilterClient" 
     android:layout_marginTop="10dp" 
     layout="@layout/footer" > 
    </include> 
    </RelativeLayout> 
+1

안드로이드 사용해보십시오 : 귀하의 목록보기가 화면 크기에 따라 크기를 조정할 수 있도록 무게를. – Venky

답변

0

당신은 장치의 화면 크기에 따라 행의 어떤을 predecide 다음 row.you 명시 적으로 안드로이드를주지해야 각각의 높이를 계산 할 필요가 없습니다. 당신은 화면의 높이를 얻을 수 있으며,이를 참조 할 수 있습니다 목록보기에서 행의 어떤을 결정 :

private int retrieveDimensions() { 
     int noOfRows= 0; 
     int screenSize = getResources().getConfiguration().screenLayout & 
       Configuration.SCREENLAYOUT_SIZE_MASK; 

     switch(screenSize) { 
     case Configuration.SCREENLAYOUT_SIZE_LARGE: 
     case Configuration.SCREENLAYOUT_SIZE_XLARGE: 
      noOfRows= 5; 
      break; 
     case Configuration.SCREENLAYOUT_SIZE_NORMAL: 
      noOfRows= 4; 
      break; 
     case Configuration.SCREENLAYOUT_SIZE_SMALL: 
      noOfRows= 3; 
      break; 
    }