我想在xml中兩次添加相同的id(相鄰),但它一直顯示錯誤,並且不能按預期工作(我想將這兩個代碼塊放在一起而不是一個在另一個之下,我非常新的Android和沒有對這一線索,任何想法如何在我的XML中兩次添加相同的ID?
<?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]:
嗯...給他們不同的'ID's? – codeMagic
它可能有助於理解XML不是代碼。它是數據,數據的格式由特定的規則決定。你不能簡單地重新安排「塊」,如你所願。 – Simon
這就是我需要的,我怎麼去layoutwise? http://i.stack.imgur.com/TgfZl.png –