2012-04-19 4 views
0

나는 왼쪽에있는 항목을 나열하는 list_item.xml 파일을 가지고 있는데, 중력 및 layout_gravity로이 항목을 오른쪽에 나열하려고했습니다. list_item .xml을 의미하지만, 이들 아무것도 바뀌지 않았다. 그냥 내가 다른 XML 파일이 있는지 언급 : item.xml는, item_list.xml,이 파일이 list.xml오른쪽의 제품 목록

enter image description here

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" 
      android:id="@+id/list_container" 
      android:measureAllChildren="true" 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:orientation="vertical" > 

     <ListView 
      android:id="@android:id/list" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:drawSelectorOnTop="false" 
      android:focusableInTouchMode="true" 
      android:paddingBottom="10sp" 
      /> 

     <ScrollView android:id="@+id/edit_layout" 
      android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
      android:visibility="gone> 

      <LinearLayout 
       android:orientation="vertical" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:paddingTop="5sp" 
       android:paddingLeft="10sp" 
       android:gravity="right" 
       android:paddingRight="15sp" 
       > 


       <TextView 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="@string/list_notes_label" 
        android:gravity="right" 
       /> 
     <!-- I have many other of text views --> 
      </LinearLayout> 
     </ScrollView> 
    <com.google.ads.AdView 
      android:id="@+id/adView" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true"> 
     </com.google.ads.AdView> 
    </RelativeLayout> 

item.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:orientation="vertical" 
android:gravity="right" > 

<ImageView 
    android:id="@+id/image" 
    android:layout_width="50dp" 
    android:layout_height="50dp" /> 

<TextView 
    android:id="@+id/caption" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_toRightOf="@id/image" 
    android:textSize="18sp" /> 

<TextView 
    android:id="@+id/description" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/caption" 
    android:layout_toRightOf="@id/image" /> 

list_item.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" 
android:orientation="vertical" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:paddingTop="6dip" 
android:paddingBottom="6dip" 
android:paddingLeft="20dip" 
android:gravity="right"> 


<TextView android:id="@android:id/text1" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:textAppearance="?android:attr/textAppearanceLarge" 
/> 



<TextView android:id="@android:id/text2" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:textAppearance="?android:attr/textAppearanceSmall" 
/> 

+0

목록보기의 항목을 오른쪽 정렬하려면 항목의 XML을 게시하여 변경 방법을 제안 할 수 있도록 – dymmeh

+0

padding_right를 0으로 설정하고 padding_left를 사용하여 설정할 수 있다고 생각합니다. – Guillaume

+0

item.xml 및 모든 것이 올바르게 정렬되어 있습니다 ..? – dymmeh

답변

0

각 TextView 및 ImageView에 android:layout_alignParentRight="true"을 추가하십시오.

관련 문제