2013-08-06 5 views
2

무엇이 일어나고 있는지 설명하는 것보다 here님께 서 스크린을 움켜 잡으실 수 있습니다.내 listView에있는 항목이 제대로 정렬되지 않습니까?

내 품목 목록은 해당 가게의 aaaalll입니다.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:orientation="vertical" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:background="#121212"> 
<ImageView 
android:id="@+id/imageView1" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:src="@drawable/logo" /> 
<TextView 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:text="@string/main_title" 
android:textColor="#33b5e5" 
android:background="#1f1f1f" 
android:textStyle="bold" 
android:textSize="14sp"/> 
<ListView 
android:id="@+id/android:list" 
android:background="#121212" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:dividerHeight="2dip"/> 
</LinearLayout> 

LIST_ROW.XML

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="?android:attr/listPreferredItemHeight" 
android:padding="6dip" 
android:background="#121212"> 
<TableLayout 
android:layout_width="fill_parent" 
android:layout_weight="1" 
android:layout_height="fill_parent" 
android:stretchColumns="*" 
android:background="#121212"> 
<TableRow> 
<ImageView 
android:id="@+id/icon" 
android:padding="2dip" 
android:background="#121212"/> 
<TextView 
android:id="@+id/description" 
android:padding="2dip" 
android:textSize="18sp" 
android:textColor="#ffffff" 
android:singleLine="true" 
android:background="#121212"/> 
</TableRow> 
</TableLayout> 
</LinearLayout> 

답변

0

Table layout

을 제거

ACTIVITY_MAIN.XML list_row.xml, activity_main.xml하고 목록의 형식을 다른 두를 붙여 가고 이것을 사용하십시오

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="64dp" 
    android:background="#121212" 
    android:orientation="horizontal" 
    android:padding="6dip" > 

    <ImageView 
     android:id="@+id/icon" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:background="#121212" 
     android:padding="2dip" 
     android:src="@drawable/instructions" /> 

    <TextView 
     android:id="@+id/description" 
     android:layout_width="0dp" 
     android:layout_weight="1" 
     android:layout_height="match_parent" 
     android:background="#121212" 
     android:padding="2dip" 
     android:singleLine="true" 
     android:text="tomer" 
     android:textColor="#ffffff" 
     android:textSize="18sp" /> 

</LinearLayout> 
+0

목록이 왼쪽으로 정렬되었지만이를 확인할 수 있습니다. 센터 정렬을 원했지만 이것이 가능합니다. –

0

android : layout_weight와 같은 ImageView 및 TextView에 원하는 비율로 가중치를 부여하십시오. Android를 만드는 것을 잊지 마세요 : layout_width = "match_parent"그렇지 않으면 가중치가 아무런 영향을 미치지 않습니다 ..

관련 문제