Я пытаюсь, чтобы изображение было слева, справа от него, вертикальным списком (название, адрес и дата) и справа от всего URL-адреса. Кажется, я не могу заставить URL-адрес отображаться в любом месте, кроме заголовка. Может ли кто-нибудь указать мне в правильном направлении?
<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"
/>
С этой текущей попыткой XML с URL-адресом справа от @id/date... он вообще не отображается. Если я поместил его вRightOf = "@id/icon", он появится буквально сверху, а не над заголовком.
Спасибо за любую помощь!
Вот 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"
/>
Спасибо всем за ваши знания!
Посмотрите на следующее:
<?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 (горизонтальной и вертикальной).
The HeirarchyViewer под инструментами может помочь вам понять, что происходит. Поскольку у вас есть ширина макета, установленная на fill_parent, а не wrap_content, возможно, что ваш @id/date не отображается, потому что он отображается с экрана.
Трудно сказать из вашего описания, что именно вы пытаетесь выполнить, вы можете добавить рис. Однако вы пытались указать @id/date для выравнивания родительского права слева или справа?