【发布时间】:2013-11-16 21:02:36
【问题描述】:
我试图在 xml 中添加相同的 id 两次(彼此相邻),但它一直向我显示错误并且无法按预期工作。(我想将这两个代码块放在每个旁边其他而不是其他,我对android很陌生,对此一无所知,有什么想法吗?
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:foo="http://schemas.android.com/apk/res/com.justin.jar"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#004D79"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="@dimen/news_headline_padding" >
<com.justin.jar.utils.FontTextView
android:id="@+id/news_headline_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="3"
android:paddingLeft="@dimen/common_left_padding"
android:paddingRight="5dp"
android:textSize="16sp"
foo:customFont="cabin.medium.ttf"
android:textColor="@color/search_autosuggest_header_text"
android:layout_toRightOf="@id/news_headline_image" />
<com.justin.jar.utils.FontTextView
android:id="@+id/metadata"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/search_autosuggest_item_subtitle"
android:textSize="12sp"
android:paddingLeft="@dimen/common_left_padding"
android:paddingRight="5dp"
android:layout_alignLeft="@id/news_headline_text"
android:layout_toRightOf="@id/news_headline_image"
android:layout_below="@id/news_headline_text"
/>
<ImageView
android:id="@+id/news_headline_image"
android:layout_width="107dp"
android:layout_height="80dp"
android:background="@drawable/container_dropshadow"
android:paddingLeft="1dp"
android:paddingRight="1dp"
android:paddingTop="1dp"
android:paddingBottom="1dp"
android:layout_alignParentLeft="true"
android:layout_marginLeft="@dimen/common_left_padding"
android:contentDescription="@string/headline_image"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="@dimen/news_headline_padding" >
<com.justin.jar.utils.FontTextView
android:id="@+id/news_headline_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="3"
android:paddingLeft="@dimen/common_left_padding"
android:paddingRight="5dp"
android:textSize="16sp"
foo:customFont="cabin.medium.ttf"
android:textColor="@color/search_autosuggest_header_text"
android:layout_toRightOf="@id/news_headline_image" />
<com.justin.jar.utils.FontTextView
android:id="@+id/metadata"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/search_autosuggest_item_subtitle"
android:textSize="12sp"
android:paddingLeft="@dimen/common_left_padding"
android:paddingRight="5dp"
android:layout_alignLeft="@id/news_headline_text"
android:layout_toRightOf="@id/news_headline_image"
android:layout_below="@id/news_headline_text"
/>
<ImageView
android:id="@+id/news_headline_image"
android:layout_width="107dp"
android:layout_height="80dp"
android:background="@drawable/container_dropshadow"
android:paddingLeft="1dp"
android:paddingRight="1dp"
android:paddingTop="1dp"
android:paddingBottom="1dp"
android:layout_alignParentLeft="true"
android:layout_marginLeft="@dimen/common_left_padding"
android:contentDescription="@string/headline_image"
/>
</RelativeLayout>
</FrameLayout>
这是我想要的示例 http://i.stack.imgur.com/TgfZl.png
[1]:
【问题讨论】:
-
嗯...给他们不同的
ids? -
理解 XML 不是代码可能会有所帮助。它是数据,数据的格式是由一定的规则决定的。您不能随心所欲地重新排列“块”。
-
这就是我需要的,我该如何布局呢? i.stack.imgur.com/TgfZl.png
-
链接的图像似乎与这个问题无关。烂网址?
标签: android android-layout android-fragments android-linearlayout