Search code examples
androidandroid-layoutandroid-edittextandroid-linearlayout

EditText disappeared after being placed in a linear layout


When i placed my edit text into a linear layout to stop it from lagging is disappeared from the app screen and now my app crashes when its launched.(the ending of the code such as /linearLayout> is there it just wont show up on here) old code:

<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" />

new code:

<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" />


Solution

  • You typed the wrong tag for opening a LinearLayout. It should be a capital 'L', not a lowercase 'l'. Also, you need to set the orientation of a LinearLayout to either vertical or horizontal:

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