我正在尝试将图像放在左侧,右侧,垂直列表(标题,地址和日期)以及所有网址的右侧。我似乎无法在任何地方显示网址,但在标题之上。有人能指出我正确的方向吗?
<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"
/>
使用@ id / date右侧的url进行当前的XML尝试...它根本不显示。如果我把它放到RightOf =“@ id / icon”,它就会出现在标题之上,而不是标题之上。
感谢您的帮助!
答案 0 :(得分:0)
HeirarchyViewer,在工具下,可能会帮助您了解最新情况。由于您的布局宽度设置为fill_parent,而不是wrap_content,因此可能不会显示您的@id / date,因为它正在屏幕上呈现。
很难从你的描述中准确地告诉你要完成什么,你可以添加一张照片。但是,您是否尝试告诉@id / date将父对齐左对齐?
答案 1 :(得分:0)
请查看以下内容:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content" android:layout_width="fill_parent">
<ImageView android:id="@+id/ImageView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/icon">
</ImageView>
<TextView android:layout_height="wrap_content"
android:text="@+id/title"
android:layout_width="wrap_content"
android:layout_toRightOf="@+id/ImageView01"
android:id="@+id/title">
</TextView>
<TextView android:layout_below="@+id/title"
android:layout_height="wrap_content"
android:text="@+id/address"
android:id="@+id/address"
android:layout_toRightOf="@+id/ImageView01"
android:layout_width="wrap_content">
</TextView>
<TextView android:layout_below="@+id/address"
android:layout_height="wrap_content"
android:text="@+id/date"
android:id="@+id/date"
android:layout_toRightOf="@+id/ImageView01"
android:layout_width="wrap_content">
</TextView>
<TextView android:layout_below="@+id/title"
android:layout_height="wrap_content"
android:text="@+id/url"
android:id="@+id/url"
android:layout_toRightOf="@+id/address"
android:layout_width="fill_parent">
</TextView>
</RelativeLayout>
这是你的想法吗?另外我建议考虑LinearLayouts的组合(水平和垂直)。
答案 2 :(得分:0)
这是我编写的XML,它可以根据需要进行布局。
<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="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/icon"
android:layout_below="@id/address"
android:textSize="12dip"
android:singleLine="true"
android:ellipsize="end" />
<TextView
android:id="@+id/url"
android:layout_marginLeft="10dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/date"
android:layout_alignBaseline="@id/date"
android:autoLink="web"
android:textColorLink="#7d26cd"
/>
谢谢大家的知识!