2011-01-14 5 views
16

내 레이아웃에 ListView가 있습니다. 나는 모든 항목 사이의 거리를 갖고 싶어Listview의 항목 간 거리

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" 
    android:background="@drawable/selector_custombutton" 
    android:padding="10dp" 
    android:layout_gravity="center"> 
    <TextView 
     android:id="@+id/text_history_station_name" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:gravity="center_vertical|left" 
     android:textColor="@color/rnv_blue_540c"/> 
    <TextView 
     android:id="@+id/text_history_line_id" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:gravity="center_vertical|left" 
     android:textColor="@color/rnv_blue_540c"/>  
</LinearLayout> 

: 같은

<ListView 
     android:id="@+id/list_infoitems" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content"/> 

모든 목록 항목 레이아웃 보인다. 저것을 위해 나는 안드로이드로 놀았다 : margin 재산, 그러나 성공없이.

아무도, 어떻게 목록보기에서 항목 사이의 거리를 변경 알아요.

뮤르에게,

+0

각 행 사이의 거리? 또는 행에 나타나는 각 항목 사이에? –

+0

각 행 사이 = 목록 항목 – Tima

답변

29

언제든지 dividerHeight 속성을 설정할 수 있습니다. 즉 없습니다 당신이 무엇을 원하는 경우 Android Docs

<ListView 
    android:id="@+id/list" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:dividerHeight="5dp" 
/> 

, 당신의 목록보기 항목에서 당신은 RelativeLayout의에있는 LinearLayout을 포장 할 수 사이의 거리를 encrease하려면있는 LinearLayout

<RelativeLayout 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <LinearLayout 
     android:id="@+id/list" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_marginTop="5dp" 
     android:layout_marginBottom="5dp" 
    /> 
</RelativeLayout> 
+0

두 번째 제안과 같은 아이디어가 있었지만 첫 번째 도움이 더 좋았습니다 :) 감사합니다. – Tima

+3

이것은 내 목록을 제외하고는 저에게 효과적이었습니다 검은 색이고 칸막이는 회색입니다. 구분선을 목록과 같은 색으로 변경하십시오! android : divider = "# 00000"내 경우에. – NPike

+1

@NPike 또는 # 00000000 – softarn

0

사용 패딩이나 마진 또는 ListView에 자체 감사합니다.

<ListView 
     android:id="@+id/list_infoitems" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:padding="5px" 
/> 
+0

아니오, 도움 안됨 – Tima

0

에 여백을 추가 당신이 사용할 수있는 항목들을 자기

android:dividerHeight="xxdpi" 

에서

Regarts, 마르코

+0

으로 구분선을 투명하게 만들었습니까? – Tima

1

I리스트 뷰 분할이 조각화 문제가 있음을 발견했다. 2.3 장치에서는 기본적으로 4.x 장치에 표시되지 않는 회색 선이 구현됩니다. 수동으로 android:divider="some_value"을 설정하여 해결할 수 있습니다. 필자는 항목 레이아웃 자체 내에서 모든 ListView 항목 레이아웃 문제를 처리하는 경향이 있습니다. 그것의 더러운 작은 속임수지만, 크로스 버전 문제를 해결합니다. 아래에 "숨겨진"보기가 추가되었습니다. 이렇게하면 항목 간의 문제가 해결 될뿐만 아니라 목록의 마지막 항목 이후에 동일한 채우기가 제공됩니다.

<RelativeLayout 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 

    <LinearLayout 
     android:id="@+id/list" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_marginTop="5dp" /> 

    <View 
     android:below="@id/list" 
     android:layout_height="0dp" 
     android:layout_width="0dp" 
     android:margin_top="5dp" /> 
</RelativeLayout> 
관련 문제