2012-11-27 19 views
2

我在使用ListView中的RelativeLayout時遇到問題。我希望兩個EditText字段一個在另一個之上,而不是它們完全重疊。我有更多的文字放在每一行,所以並排不是一個選項。無法使RelativeLayout在列表視圖中工作

我試着取出所有多餘的代碼,使其工作,所以這是我有:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" > 

<ListView android:id="@android:id/list" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" /> 

</LinearLayout> 

這裏是我的相對佈局:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 

    <EditText 
     android:id="@+id/time" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textSize="20sp" /> 


    <EditText 
     android:id="@+id/room" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/time" 
     android:textSize="20sp" /> 

</RelativeLayout> 

任何幫助將不勝感激。謝謝。

+0

您第二個edittext應該有android:layout_below =「@ + id/time」。 – KunalK

回答

2

更換

android:layout_below="@id/subject" 

隨着

android:layout_below="@+id/time" 

因此,與ID室,EditText上會下面的EditText id爲時間。

+2

@hotveryspicy OP編輯了他的問題。請您在介紹答案之前仔細閱讀編輯,或者您喜歡這樣做?.OP之前給出了一些其他ID,而不是@ id/time。 –

+2

我認爲@VipulShah從他的角度來看是正確的,他也指出了一些實際的東西,這些東西混淆了視圖。一個人應該閱讀在投票前做出的要求和編輯。 – AkashG

0

使用的LinearLayout這個用例

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:orientation="vertical> 

<EditText 
    android:id="@+id/time" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:textSize="20sp" /> 


<EditText 
    android:id="@+id/room" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:textSize="20sp" /> 

</LinearLayout> 
1

您需要更換機器人:layout_below = 「@ ID /主題」 到Android:layout_below = 「@ + ID /時間」

相關問題