2

i am creating a chat app like whatsapp on my chatting screen i have edittext where user can enter his message. i want to expand its height to max 4 line then if text exceed to 5th line the edittext have to scroll down showing new line. sometimes it work but sometimes edit text doesnot scroll down.

 <com.vanniktech.emoji.EmojiEditText
                android:id="@+id/enter_msg_txt"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="9.2"
                android:background="@null"
                android:hint="@string/type_message"
                android:maxHeight="100dp"
                android:minHeight="30dp"
                android:singleLine="false"
                android:textSize="@dimen/btn_text" />

i had already search alot and check with these properties

android:inputType="textMultiLine"
            android:editable="true"
            android:enabled="true"
            android:minLines="1"
            android:maxLines="6"
            android:isScrollContainer="true"

but still no luck. i think there is may be some rendering issue

4 Answers4

0

This library may solve your problem. https://github.com/ViksaaSkool/AutoFitEditText. Try it!

Hien Quang Le
  • 158
  • 2
  • 6
0

Use this line of code

<EditText
    android:inputType="textMultiLine"
    android:lines="int number" <!-- Total Lines prior display -->
    android:layout_height="wrap_content"
    android:layout_width="fill_parent"
    android:scrollbars="vertical"/>
Donald Duck
  • 8,409
  • 22
  • 75
  • 99
Vishal Sharma
  • 1,051
  • 2
  • 8
  • 15
0

This worked for me (try it with your view )

  • use height as wrap content,
  • use lines as lines count you want, so after scroll down is done

    <EditText
    android:id="@+id/reviewEditText"
    android:layout_width="100dp"
    android:layout_height="wrap_content"
    android:lines="3"
    android:scrollbars="vertical"
    />
    

and sure that windowSoftInputMode="adjustResize"

Mahmoud Mabrok
  • 1,362
  • 16
  • 24
-1

Please try this

    <EditText
android:id="@+id/chatText"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:textSize="20sp"
 android:inputType="text" 
 android:maxLines="1"
 android:lines="1"
 android:scrollHorizontally="true"
 android:ellipsize="end"/>
charan reddy
  • 38
  • 1
  • 8