2013-06-07 3 views
0

엉 무게 :안드로이드리스트 뷰 항목을 작성 부모 나는이 목록보기 가지고

  <ListView 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:id="@+id/listView2" 
       android:divider="#CCCCCC" 
       android:dividerHeight="1px" 
       android:cacheColorHint="#00000000" /> 

목록보기에 내가있는 LinearLayout로드 : 난 1의 무게를 가지고이있는 LinearLayout에서

 <LinearLayout 
      android:layout_weight="1" 
      android:layout_height="fill_parent" 
      android:layout_width="fill_parent" 
      android:background="#ffffff"/> 

를, 그래서 목록이로드되면 모든 항목간에 동일하게 나누어집니다. 이제 문제는 이것이 작동하지 않는다는 것인데, 이것은 가능한 부엉 체중과리스트 뷰의 아이템을로드하는 것입니까?

+0

나는 이것이 작동하지 않을 것이라고 생각합니다 - 목록보기 항목이 목록의 다른 항목에 대해 "아는 것"이라고 생각하지 않습니다 ... 이는 항목 간의 layout_weight에 대한 요구 사항입니다. 그러나 나는 누군가가 나를 틀리게 증명하도록 내버려 둘 것이다. –

+0

fill_parent는 API 레벨 8부터 사용되지 않으며 match_parent로 대체됩니다. –

답변

1

가중 속성은 LinearLayout입니다. 부모 레이아웃은 LinearLayout이어야합니다. 그래서 당신이 작성한 코드가 가능한 시나리오라고 생각하지 않습니다.

무게를 지정할 때마다 너비 또는 높이를 0dp로 설정해야합니다.

<LinearLayout 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:weightSum="5"> 

<Button 
    android:layout_width="0dp" 
    android:layout_height="wrap_content" 
    android:layout_weight="1" 
    android:text="1" /> 

<Button 
    android:layout_width="0dp" 
    android:layout_height="wrap_content" 
    android:layout_weight="3" 
    android:text="2" /> 

<Button 
    android:layout_width="0dp" 
    android:layout_height="wrap_content" 
    android:layout_weight="1" 
    android:text="3" /> 

</LinearLayout> 
+3

fill_parent는 API 레벨 8부터 사용되지 않으며 match_parent로 대체됩니다. –