列出右边的项目

时间:2012-04-19 15:28:53

标签: android xml layout

我有list_item.xml文件,其中列出左侧的项目,我一直在尝试使用gravity和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"
/>

1 个答案:

答案 0 :(得分:0)

在每个TextView和ImageView上添加android:layout_alignParentRight="true"

相关问题