Reputation: 2849
I have a large layout inside a ScrollView
. There are a few EditTexts
Which have maxHeight
set to 100dp
.
The problem is when I copy and past a long text into my EditText
the height of it does not increase from maxHeight
(which is normal), but the parent ScrollView
scrolls to the end. It seems that ScrollView
does not understand the maxHeight
attribute of the EditText
and behaves like there is no maxHeight
and EditText
has increased its height to wrap the content of the pasted long text.
It seems this issue is fixed on Android 7+, but on older versions this problem exists.
There is nothing interesting in my layout so I will not put it here. It is just a ScrollView
which has a vertical LinearLayout
inside, and LinearLayout
has a bunch of views and a few EditTexts
like the following:
<EditText
android:id="@+id/layout_free_text_et"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="48dp"
android:maxHeight="100dp"
android:paddingStart="15dp"
android:paddingEnd="15dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:background="@drawable/section_background"
android:textColor="@color/white"
android:textColorHint="@color/gray"
android:textSize="@dimen/section_text_size"
android:hint="@string/hint_free_text"/>
I have tried to add different attributes to EditText
, like maxLine
etc. seems nothing solves the issue. I googled a lot, but there is nothing even similar to this issue anywhere. Can anybody suggest me a solution to this problem?
Upvotes: 0
Views: 95
Reputation: 165
you can use this android:lines="2"
it also makes you can scroll the EditText
Upvotes: 1