安卓——a";的XML帮助;复杂的;列表视图中的行

安卓——a";的XML帮助;复杂的;列表视图中的行,xml,android,listview,Xml,Android,Listview,我有一个相对复杂的布局,我想成为Android中ListView的“行”,我很难在每一行上显示最正确的元素 下面是行的外观: 左侧有一个图标(50dip x 50dip),右侧有一个图标(9x13)。图标应该是左对齐和右对齐,中间用可变文本。 问题是,我最右边的图标(9 x 13)使用我当前的XML布局被推离可见区域,我尝试的修复都失败了 建议 !![备选案文][1] [1] : 为什么不将相对性yout与alignParentLeft和alignParentRight属性一起使用呢?我认为这会

我有一个相对复杂的布局,我想成为Android中ListView的“行”,我很难在每一行上显示最正确的元素

下面是行的外观:

左侧有一个图标(50dip x 50dip),右侧有一个图标(9x13)。图标应该是左对齐和右对齐,中间用可变文本。 问题是,我最右边的图标(9 x 13)使用我当前的XML布局被推离可见区域,我尝试的修复都失败了

建议

!![备选案文][1]

[1] :


为什么不将
相对性yout
alignParentLeft
alignParentRight
属性一起使用呢?我认为这会更简单,使用更少的裁员经理。如下所示:注意,这假设行的高度为50dip,两个图像的高度均为50x50 dip

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="50dip"
    android:layout_width="fill_parent"
    android:layout_weight="0">
<ImageView 
    android:layout_height="50dip"
    android:layout_width="50dip"
    android:layout_alignParentLeft="true"
    android:layout_centerVertical="true"/>
<TextView
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:layout_centerInParent="true" 
    android:text="some text"/>
<ImageView 
    android:layout_height="50dip"
    android:layout_width="50dip"
    android:layout_alignParentRight="true"
    android:layout_centerVertical="true"/>
</RelativeLayout>


TextView中要添加的一个内容是android:layout_margin=“50dp”,在其他情况下,长文本将与图像重叠。另一个一般布局提示:您可以使用
android:leftDrawable
属性(或
SetCompoundDrawableSwithinInsticBounds
方法)使用
TextView
来避免甚至需要左侧的
ImageView
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="50dip"
    android:layout_width="fill_parent"
    android:layout_weight="0">
<ImageView 
    android:layout_height="50dip"
    android:layout_width="50dip"
    android:layout_alignParentLeft="true"
    android:layout_centerVertical="true"/>
<TextView
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:layout_centerInParent="true" 
    android:text="some text"/>
<ImageView 
    android:layout_height="50dip"
    android:layout_width="50dip"
    android:layout_alignParentRight="true"
    android:layout_centerVertical="true"/>
</RelativeLayout>