2013-12-14 24 views
2

我有一個相對的佈局裏面的滾動視圖。當我將相對佈局高度設置爲match_parent時,它會將其設置爲圖形佈局,我不知道它爲什麼這樣做。 ---下面的圖片---爲什麼我的發送按鈕與我的編輯文本重疊?

Button Over Lapping Edit Text Box

這裏是activity_main.xml中的文件:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    tools:context=".MainActivity" >  

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" > 

    <EditText 
     android:id="@+id/etName" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignLeft="@+id/textView1" 
     android:layout_below="@+id/textView1" 
     android:ems="10" 
     android:hint="First and Last Name" 
     android:inputType="textPersonName" > 

     <requestFocus /> 
    </EditText> 

    <EditText 
     android:id="@+id/etPhone"  
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/etName" 
     android:layout_marginTop="14dp" 
     android:ems="10" 
     android:hint="Enter Phone #" 
     android:inputType="phone" /> 

    <EditText 
     android:id="@+id/etEmail" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/etPhone" 
     android:layout_marginTop="17dp" 
     android:ems="10" 
     android:hint="Enter E-mail" 
     android:inputType="textEmailAddress" /> 

    <EditText 
     android:id="@+id/etAdd" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"  
     android:layout_below="@+id/etEmail" 
     android:layout_marginTop="18dp" 
     android:ems="10" 
     android:hint="Additional Information" 
     android:lines="5" 
     android:inputType="textMultiLine" /> 

    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignLeft="@+id/etPhone" 
     android:layout_alignParentTop="true" 
     android:gravity="center" 
     android:text="Contact Form" 
     android:textAppearance="?android:attr/textAppearanceMedium" /> 

    <Button 
     android:id="@+id/send" 
     android:layout_width="match_parent" 
     android:layout_height="125dp" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentLeft="true" 
     android:text="Send" /> 

</RelativeLayout> 

</ScrollView> 

我也曾嘗試設置滾動視圖的寬度和高度,以FILL_PARENT,它仍然一樣的東西。我究竟做錯了什麼?

預先感謝您!

回答

1

您還沒有指定按鈕

的正確定位添加android:layout_below="@+id/etAdd"到您的按鈕

<Button 
     android:id="@+id/send" 
     android:layout_width="match_parent" 
     android:layout_height="125dp" 
     android:layout_below="@+id/etAdd" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentLeft="true" 
     android:text="Send" /> 
+0

感謝您的建議,不幸的是它仍然無法正常工作。我很困惑,哈哈 – OliverTwist

+0

沒關係。我離題了。我錯過了它的佈局部分。謝謝你有點陌生 – OliverTwist

1

試試這個,

<Button 
     android:id="@+id/send" 
     android:layout_width="match_parent" 
     android:layout_height="125dp" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentLeft="true" 
     android:layout_below="@+id/yourEdt" 
     android:text="Send" /> 
+0

感謝您的建議,遺憾的是它仍然是不加工。 – OliverTwist

+0

你提到你的按鈕高度爲125dp,它必須根據125dp對齊你的底部,所以它在edittext中重疊 –

+0

謝謝。它只是缺少android:的佈局部分。所以,當你輸入android:layout_below時它會起作用。 – OliverTwist

相關問題