bdpolinsky bdpolinsky - 20 days ago 12
Android Question

Android textview is missing the line underneath

I recently updated to Android Studio 2.2.2.
I am looking to add a textview to one of my apps. But, when I drag and drop an edittext into the layout, the line underneath, or anything denoting that its a separate input; the only formatting makes it appear just as the background. That is, the input has no formatting.

I would like it to have some sort of formatting; either a border, a single line underneath, so that the user can see where to click and enter their information.

What properties do I need to do this, and where can they be manipulated?

This is the XML

<android.support.design.widget.TextInputLayout
android:id="@+id/location_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:divider="@android:string/ok">

<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:text="@string/name"
android:ems="10"
android:id="@+id/editText7"
android:layout_below="@+id/MemeMe"
android:layout_centerHorizontal="true"
android:layout_marginTop="31dp" />

</android.support.design.widget.TextInputLayout>


And this is what it looks like

enter image description here
Normally I'd drag and drop from the widget bar on the left side of android studio, but it doesn't seem like Android Studio did such a thing in this case, and its probably not wise to rely on the IDE to do such things like that without me knowing how it does the things.

Answer

Try this:

        <android.support.design.widget.TextInputLayout
            android:id="@+id/location_layout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <EditText
                android:id="@+id/location"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="@string/location"/>

        </android.support.design.widget.TextInputLayout>
Comments