Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Edit text overlaps each other

I am creating an android application in which i am collecting user's some messages.But i am getting some issues such as following..

I have added 3 edit text in alert dialog..the third edit text box having multi line textbox so whenever i am adding multiple lines its getting overlapped to above two edit text

here is the snapshot of the error

This one is perfect text

Here is issue

Here Is Layout file

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1">
<ScrollView
android:layout_width="245dp"
android:layout_height="245dp"
android:layout_weight="0.40"
android:layout_gravity="center_horizontal">
<RelativeLayout
    android:layout_width="245dp"
    android:layout_height="200dp">
<EditText
    android:layout_width="235dp"
    android:layout_height="wrap_content"
    android:inputType="textEmailAddress"
    android:ems="10"
    android:id="@+id/editText6"
    android:layout_gravity="center_horizontal"
    android:hint="Your Email Id"
    android:layout_alignBaseline="@+id/editText5"
    android:layout_alignBottom="@+id/editText5"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true" />

<EditText
    android:layout_width="240dp"
    android:layout_height="wrap_content"
    android:id="@+id/editText4"
    android:layout_gravity="center_horizontal"
    android:hint="Title"
    android:singleLine="true"
    android:layout_centerVertical="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true" />

<EditText
    android:layout_width="236dp"
    android:layout_height="wrap_content"
    android:inputType="textMultiLine"
    android:ems="10"
    android:id="@+id/editText5"
    android:hint="Description"
    android:layout_gravity="center_horizontal"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true" /></RelativeLayout></ScrollView>

   <Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Submit"
    android:id="@+id/button10"
    android:layout_gravity="center_horizontal" />

 </LinearLayout>
like image 655
Nilesh Indalkar Avatar asked Oct 30 '22 13:10

Nilesh Indalkar


1 Answers

Reason for your issue is android:inputType="textMultiLine" pushes content when there is a new line!

  • You can use android:maxLines="1" for your EditText [any way this will be useful for you since you have used android:singleLine="true" with is kind of dipricated ]

Ps: Hard coding android:maxLength will not solve your issue since screens can be in different sizes which makes you hard to decide how many lines you keep!

Also you can use android:maxHeight="xdp" for the editText view, then the limit won't exeed!

like image 186
Charuක Avatar answered Nov 09 '22 06:11

Charuක