我想要在左边,右边的一个垂直列表(标题,地址和日期),以及所有网址的右侧。我似乎无法让网址显示在标题顶部的任何地方。任何人都可以将我指向正确的方向吗?相对布局的问题
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:padding="6dip">
<ImageView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:layout_marginRight="6dip"
/>
<TextView
android:id="@+id/title"
android:layout_width="fill_parent"
android:layout_height="20dip"
android:layout_toRightOf="@id/icon"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:textStyle="bold"
android:singleLine="true"
android:ellipsize="marquee"
/>
<TextView
android:id="@+id/address"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="12dip"
android:layout_toRightOf="@id/icon"
android:layout_alignParentRight="true"
android:layout_below="@id/title"
/>
<TextView
android:id="@+id/date"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/icon"
android:layout_below="@id/address"
android:layout_alignParentRight="true"
android:textSize="12dip"
android:singleLine="true"
android:ellipsize="end" />
<TextView
android:id="@+id/url"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/date"
/>
用的URL @ ID /日期右边这个电流XML的尝试......它不会出现在所有。如果我将它放置到RightOf =“@ id/icon”,它就会出现在字幕上方,而不是字幕上方。
感谢您的帮助!
我确实弄清楚了我的问题......这是我在日期元素中有“fill_parent”。由于优化,我也试图远离LinearLayouts。在这个URL(http://android-developers.blogspot.com/2009/02/android-layout-tricks-1.html)它声称“这种布局的工作(LinearLayout),但可以浪费如果你实例化它ListView的每个列表项目,可以使用单个RelativeLayout重写相同的布局,从而节省一个视图,甚至更好地在视图层次结构中的每个列表项目的一个级别。“ – taraloca 2010-08-07 11:49:56
我的意思是告诉你,我试过你的XML,它也可以工作!谢谢! – taraloca 2010-08-07 12:07:29
好帖子!感谢您指出。 – Asahi 2010-08-07 12:23:31