2012-10-29 69 views
0
<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:padding="20dp"> 

<RelativeLayout 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:background="@drawable/content"> 

<ImageView 
android:id="@+id/idcontentline" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:layout_gravity="center|top" 
android:src="@drawable/line" 
android:layout_marginTop="10dp" 
android:layout_marginBottom="10dp" 
android:layout_centerHorizontal="true"/> 

<ScrollView 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:layout_below="@+id/idcontentline" 
android:layout_centerHorizontal="true" 
android:scrollbarStyle="insideInset" 
android:scrollbars="vertical" > 

<TextView 
android:id="@+id/idcontenttext" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:text="this is a sample" /> 

</ScrollView> 

</RelativeLayout> 

</RelativeLayout> 

當我使用Android:layout_below = 「@ + ID/idcontentline」,一切都是正確的,TextView的低於imageview.But時使用@id代替@ + id,這是行不通的。layout_below與@id不工作,但與@ + ID工作

怎麼了?

回答

0

幾次清理項目,就這樣。

+0

讓我們嘗試一下,我會說... –

+0

非常感謝。它的工作。 R.java已被重新創建! –

+0

它不適合我! :(另一種解決方案?wtf是這個!!? –

3

字符串開頭的符號(@)表示XML解析器應解析並展開ID字符串的其餘部分,並將其標識爲ID資源。加號(+)表示這是一個新的資源名稱,必須創建並添加到我們的資源中(在R.java文件中)。 Android框架提供了許多其他ID資源。引用Android資源ID時,不需要加號,但必須添加android包名稱空間。

+0

Exactly.question在這裏。當我們想要聲明一個新的id時,必須使用plus,並且當想要使用它時,必須@ id.but在我的問題中它不起作用。 –

+1

清潔生成您的項目比生成新的參考ID比它可能正常工作 –