0

當我將我的編輯文本放入線性佈局以阻止它滯後時,它從應用程序屏幕上消失,現在我的應用程序在其啓動時崩潰(代碼的結尾,例如/的LinearLayout>是有它只是不會出現在這裏) 舊代碼:EditText被置於線性佈局後消失

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/container" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context="com.example.trucktracker.MainActivity" 
android:background="@drawable/background" 
tools:ignore="MergeRootFrame"> 


    <Button 
     android:id="@+id/continuebtn" 
     android:layout_width="match_parent" 
     android:layout_height="68dp" 
     android:layout_alignParentBottom="true" 
     android:onClick="clickedContinue" 
     android:text="@string/continue_btn" 
     android:textColor="#ffffff" 
     android:background="@drawable/btnbackreg" 
     android:layout_marginRight="7dp" 
     android:layout_marginLeft="7dp" 
     android:layout_marginTop="3dp" 
     android:layout_marginBottom="3dp" 
     android:textSize="30sp" /> 

<ImageView 
    android:id="@+id/legion" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_centerHorizontal="true" 
    android:layout_alignParentTop="true" 
    android:layout_marginBottom="262dp" 
    android:layout_marginRight="105dp" 
    android:contentDescription="@string/logo" 
    android:src="@drawable/legion" /> 

<TextView 
    android:id="@+id/question" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_above="@+id/continuebtn" 
    android:layout_alignParentLeft="true" 
    android:layout_marginBottom="162dp" 
    android:text="@string/question1" 
    android:textSize="19sp" 
    android:textColor="#ffffff" 
    tools:context=".MainActivity" /> 

<EditText 
    android:id="@+id/Phonesignup" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_above="@+id/continuebtn" 
    android:layout_alignParentLeft="true" 
    android:layout_marginBottom="65dp" 
    android:ems="10" 
    android:hint="@string/phonesignup" 
    android:inputType="phone" 
    android:textColorHint="#ffffff" 
    android:textColor="#ffffff" 
    android:textSize="20sp" > 
</EditText> 

<Spinner 
    android:id="@+id/optionselect" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_above="@+id/Phonesignup" 
    android:layout_alignTop="@+id/question" 
    android:layout_marginBottom="45dp" 
    android:layout_marginLeft="18dp" 
    android:textColor="#b32017" 
    android:layout_toRightOf="@+id/question" /> 

新代碼:

<linearLayout 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" > 

<EditText 
    android:id="@+id/Phonesignup" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_marginBottom="65dp" 
    android:ems="10" 
    android:hint="@string/phonesignup" 
    android:inputType="phone" 
    android:textColor="#ffffff" 
    android:textColorHint="#ffffff" 
    android:textSize="20sp" /> 

回答

1

您輸入了打開LinearLayout的錯誤標記。它應該是大寫的'L',而不是小寫的'l'。此外,您需要將LinearLayout的方向設置爲垂直或水平方向:

<LinearLayout 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" (or horizontal) 
>