Siva Prakash Siva Prakash - 1 month ago 8
Android Question

Android: EditText Line doesn't appear

I can't get the line that indicates where to enter the text in EditText in Android Studio 2.2.1.
Everything else works fine including EditText.
TargetSDK is 23 and MinSDK is 15.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_one"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="in.shopperstreet.delta.One"
android:background="#5bf7cd">

<TextView
android:id="@+id/siva_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/txt"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="43dp" />

<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="@+id/editText"
android:layout_above="@+id/siva_btn"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginRight="47dp"
android:layout_marginEnd="47dp"
android:layout_marginBottom="37dp"
android:width="30dp"/>
</RelativeLayout>


screenshot of my activity

Answer

You are making the height and width of the EditText as wrap_content.

Give a hint as:

android:hint="hiiiiiii" 

inside the EditText text tag, you will see where it exists

If you just want to add a line, add a View below the EditText like this:

<EditText
        android:layout_width="100dp"
        android:layout_height="wrap_content"
        android:inputType="textPersonName"
        android:ems="10"
        android:id="@+id/editText"
        android:hint="hiiiiiiiiiiiiiiii"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true"
        android:layout_marginRight="47dp"
        android:layout_marginEnd="47dp"
        android:layout_marginBottom="37dp" />

    <View
        android:layout_width="100dp"
        android:layout_height="1dp"
        android:background="@android:color/black"
        android:layout_alignBaseline="@+id/editText"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true"
        android:layout_marginRight="47dp"
        android:layout_marginEnd="47dp"/>
Comments