2014-11-01 5 views
0

나는 이런 식으로하고 싶습니다.중앙 집중식 항목 가로형 ListView

enter image description here enter image description here

가 나는 수평 목록보기가 있습니다.

<com.sample.HorizontalListView 
      android:id="@+id/hlist_collection_items" 
      android:layout_width="match_parent" 
      android:layout_height="@dimen/horizontal_list_collection_image_height" 
      android:background="#44aaaaaa" 
      android:divider="#44aaaaaa" 
      android:layout_gravity="bottom"     
      android:fadingEdgeLength="5dp" 
      custom:dividerWidth="2dp" /> 

더 많은 것을해야합니까? 그것을 위해 중앙 집중식 항목. ?? 내 ListItem XML이 아래에 있습니다.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    android:gravity="center" > 
    <ImageView 
      android:id="@+id/product_image_view_1" 
      android:layout_width="@dimen/horizontal_list_collection_item_image_height" 
      android:layout_height="@dimen/horizontal_list_collection_item_image_height" 
      android:layout_centerInParent="true" 
      android:gravity="center" 

      android:src="@drawable/loading_image" 
      android:scaleType="fitCenter" /> 
</LinearLayout> 
+0

나는 그것을 중앙 항목을 확인해야합니다. 왼쪽 정렬 아이템. –

+0

http://www.dev-smart.com/archives/34 도움이 될 수도 있습니다. –

답변

1

목록보기를 중앙에 만들겠습니까?

시도 :

android:layout_gravity="bottom|center_horizontal" 

아니면 listview 무엇 내부 중앙 집중화하려는 경우 :

android:gravity="bottom|center_horizontal" 

당신이 사용자 정의 어댑터를 팽창하는 데 사용하는 사용자 정의 어댑터의 row.xml (하나에 넣어)

업데이트

이 시도 :

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="wrap_content" //change to wrap_content 
android:layout_height="wrap_content" 
android:orientation="vertical" 
android:gravity="center" > 
<ImageView 
     android:id="@+id/product_image_view_1" 
     android:layout_width="@dimen/horizontal_list_collection_item_image_height" 
     android:layout_height="@dimen/horizontal_list_collection_item_image_height" 
     android:layout_centerInParent="true" 
     android:gravity="center" 
     android:layout_gravity="center" //add this 
     android:src="@drawable/loading_image" 
     android:scaleType="fitCenter" /> 

+0

너는 너비가 match_parent이다. center_horizontal과 같은 layout_gravity와 같은 것을 의미하지는 않습니다. –

+0

Ups, 나쁘다. row.xml에서 중앙 집중화하려고 했습니까? –

+0

나는 시도했지만 여전히 아무것도 ... –