1

I have edittext. Now my edittext is wrapping content, i dont know why, i want it stay same size but be scrollable(vertical).

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

<ImageView
    android:id="@+id/imageViewFull"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
 android:layout_weight="10"
    />

 <EditText
 android:id="@+id/editTextFull"
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 android:clickable="false"
 android:ems="10"
 android:lines="1"
 android:maxLines="5"
 android:cursorVisible="false"
 android:scrollbars="vertical"
 android:focusable="false"
  android:focusableInTouchMode="false"
 android:inputType="textMultiLine"
  >

 <requestFocus />
 </EditText>


</LinearLayout>

And in java i set text with setText

kort.es
  • 469
  • 2
  • 7
  • 25

4 Answers4

2

use:

<EditText
    android:id="@+id/editTextFull"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:clickable="false"
    android:ems="10"
    android:lines="1"
    android:maxLines="5"
    android:cursorVisible="false"
    android:scrollbars="vertical"
    android:focusable="false"
    android:focusableInTouchMode="false"
    android:inputType="textMultiLine"
     >

    <requestFocus />
</EditText>
Husnain Iqbal
  • 466
  • 6
  • 15
2

Try using EditText in ScrollView or take a look at this thread to make it scrollable programmatically.

Community
  • 1
  • 1
h4ck3d
  • 5,584
  • 15
  • 44
  • 73
0

Have you tried to set your layout_height="wrap_content"?

TronicZomB
  • 8,299
  • 7
  • 32
  • 47
  • I just realized that I have my whole layout within a `ScrollView`. Try one of those answers. It should work. – TronicZomB Feb 25 '13 at 17:12
0

this works for me:

<ScrollView 
    android:layout_height="200dp"
    android:layout_width="match_parent">
    <EditText
        android:id="@+id/Emsg"
        android:hint="@string/texthint"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="5dp"
        android:textColor="#02960B"
        android:textSize="18sp" />
</ScrollView>

i have set the height by android:layout_height="200dp"

Shoshi
  • 2,194
  • 1
  • 26
  • 42