0

I am trying to use an EditText in my app.I have used match_parent for the EditText .When i try to enter some text in that EditText then it gets shifted to left and henceforth the earlier text goes out of screen.All of this is done inside a scrollview.

I want that all the text written should be visible on the screen. Here is activity_main.xml.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity"  >

<ScrollView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">
    <EditText
        android:layout_width="match_parent"
        android:layout_height="300dp"
        android:id="@+id/editText"
        android:inputType="text"
        />
</ScrollView>
</LinearLayout>
  • Check [this](http://stackoverflow.com/a/4233683/2504962) solution – Rashin Jul 15 '16 at 12:49
  • I have edited the question.please see for this. –  Jul 15 '16 at 12:54
  • Possible duplicate of [Allow multi-line in EditText view in Android?](http://stackoverflow.com/questions/4233626/allow-multi-line-in-edittext-view-in-android) – Bharatesh Jul 15 '16 at 13:15
  • the layout_width of your ScrollView should be ``match_parent``. See answer below. – finki Jul 15 '16 at 15:09

3 Answers3

1

include android:singleLine="true" attribute in EditText

Hope that helps.

Mustansar Saeed
  • 2,730
  • 2
  • 22
  • 46
0

Try to change this :

android:inputType="text"

to this :

android:inputType="textMultiLine"
Lubomir Babev
  • 1,892
  • 1
  • 12
  • 14
0

You need to set the width of you ScrollView to match_parent. If you want to your EditText to be multiline, just add android:inputType="textMultiLine". Here's some sample code:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity">

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <EditText
        android:id="@+id/editText"
        android:layout_width="match_parent"
        android:layout_height="300dp"
        android:inputType="textMultiLine"/>
</ScrollView>

finki
  • 2,063
  • 1
  • 20
  • 23