Android: EditText Line doesn't appear

I can't get the line that indicates where to enter the text in <?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> in Android Studio 2.2.1. Everything else works fine including EditText. TargetSDK is 23 and MinSDK is 15.

wrap_content

screenshot of my activity

android,android-layout,android-edittext,android-view,

0

Ответов: 4


1 accepted

You are making the height and width of the android:hint="hiiiiiii" as EditText.

Give a hint as:

View

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

If you just want to add a line, add a EditText 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"/>

0

android:layout_above="@+id/siva_btn" is not defined anywhere so you can remove it .Here is my improved version of code of your editext

     <EditText
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:inputType="textPersonName"
    android:ems="10"
    android:id="@+id/editText"
    android:layout_marginTop="90dp"
    android:layout_marginRight="47dp"
    android:layout_marginEnd="47dp"
    android:layout_marginBottom="37dp"
    android:width="30dp"/>

and the result is this Showing edittext line


0

Go for MaterialEditText for better performance.


-1

You should change layout_width (of EditText) to match_parent or fixed size, or use

android:hint = "           ";
android,android-layout,android-edittext,android-view,
Похожие вопросы