Android相对布局放置问题

Dan*_*den 2 android listview textview relativelayout imageview

我在使用XML创建相对布局时遇到问题,列表项用于ListView中的一系列项目.我已经尝试了好几个小时,我试图让它看起来像我想要的但是不能让所有东西出现在正确的位置而不是重叠或错位.我可以获得第一个图像和下两个textview,但无法获得最后的textview和imageview.

我附上了一个线框样式的图像,说明我是如何尝试它的,并且想知道是否有人可以帮助我?

替代文字http://i26.tinypic.com/6fz702.jpg

  • 右边的ImageView是行的整个高度的设置图标,周围是否有填充?
  • 两个TextView占据了宽度的大部分.地址textview有可能文本很长,所以如果空间不足,可能需要截断,或理想情况下缩小字体大小?
  • 下一个TextView将只包含一个最多5个字符的小字符串.
  • 最后一个ImageView是一个小箭头,表示此列表项可以单击以获取更多信息.它需要像显示的那样居中.
  • 我想如果图标,最后一个textview和最后一个图像总是在列表中的同一位置/对齐方式.

如果有人可以提供一些帮助,我将非常感激.

干杯伙计们

Dan*_*den 12

对于任何有兴趣的人,我设法让这个工作.我知道寻找问题的答案是多么痛苦,而且从未完全解决过.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout"
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:padding="6dip">
<ImageView
    android:id="@+id/Icon"
    android:layout_margin="5dip"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerVertical="true" />
<TextView
    android:id="@+id/topLine"
    android:layout_height="wrap_content"
    android:layout_width="fill_parent"
    android:lines="1"
    android:layout_toRightOf="@+id/Icon"
    android:layout_toLeftOf="@+id/distance"
    android:textColor="@color/blacktext"
    android:textSize="20dip"
    android:text="Name" />
<TextView
    android:id="@+id/bottomLine"
    android:layout_height="wrap_content"
    android:layout_width="fill_parent"
    android:lines="1"
    android:layout_toRightOf="@+id/Icon"
    android:layout_below="@+id/topLine"
    android:layout_toLeftOf="@+id/distance"
    android:textColor="@color/blacktext"
    android:textSize="15dip"
    android:text="Address" />
<TextView 
    android:id="@+id/distance"
    android:layout_height="wrap_content"
    android:layout_toLeftOf="@+id/arrow"
    android:layout_centerVertical="true"
    android:layout_width="wrap_content"
    android:lines="1"
    android:textColor="@color/blacktext"
    android:textSize="12dip"
    android:text="100m" />
<ImageView 
    android:id="@+id/arrow"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:layout_margin="5dip"
    android:layout_alignParentRight="true"
    android:layout_centerVertical="true" 
    android:src="@drawable/redarrow"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)