Prasad Dixit
Prasad Dixit

Reputation: 31

Android EditText not showing multilines

I am reading data from file buffer and storing it into a string. I am loading the same string by setext to editText component. However knowing multiple lines it is displaying entire file into only a single line. My xml file is as below:

<ScrollView
        android:id="@+id/scrollView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignTop="@+id/btnlogclear"
        android:layout_toRightOf="@+id/btnemaillog" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="224dp"
            android:orientation="vertical" >

            <EditText
                android:id="@+id/editLog"
                android:layout_width="wrap_content"
                android:layout_height="177dp"
                android:ems="10"
                android:enabled="false"
                android:gravity="left|top"
                android:inputType="textMultiLine"
                android:scrollbars="vertical"
                android:scrollHorizontally="false" >

                <requestFocus />
            </EditText>
        </LinearLayout>
    </ScrollView>

It is still showing a single line.

Any clues to solve the issue.

Abhimoh

Upvotes: 1

Views: 1783

Answers (4)

Prasad Dixit
Prasad Dixit

Reputation: 31

I finally managed it by using textview and setMovementMethod(new ScrollingMovementMethod());

Thanks guys for help! Closing this post

Upvotes: 0

Sanal Varghese
Sanal Varghese

Reputation: 1486

Change the height of LinearLayout to wrap_content so that EditText will get enough space to expand.Now the EditText can only extend upto 224dp. I think that's the reason why EditText is not showing multiple lines.

Upvotes: 0

g00dy
g00dy

Reputation: 6788

Use this in the xml:

android:inputType="textMultiLine" <!-- Multiline input -->
android:minLines="6" <!-- Optional min number of lines -->
android:maxLines="10" <!-- Optional max number of Lines -->

Upvotes: 1

Suji
Suji

Reputation: 6044

Use

 android:layout_height="wrap_content"

for LinearLayout and

android:layout_height="wrap_content"

for EditText

Upvotes: 0

Related Questions