I know various questions have been asked about this before but I can't find an answer for my issue. I am working on an android application and I want an EditText field to expand as the user types into it. I want it to be a minimum size first and expand if the user types more than what the minimum allows. Here is my code so far:
<ScrollView
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:fillViewport="true" >
<linearLayout
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:orientation="vertical"
android:padding="5dp" >
<linearLayout>
...content...
</linearLayout>
<linearLayout>
...content...
</linearLayout>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:lines="7"
android:gravity="top" />
</linearLayout>
</ScrollView>
The EditText field is inside the parent linearLayout, inside the parent ScrollView. It looks fine on screen but when I go past the 7th line in the edit text field I have to use a trackball to go back up through the text field. Scrolling the screen scrolls the entire screen. Can anyone give me some tips? I've tried implementing different suggestions to similar questions but none have given me the correct answer. Thanks
As @tozka has stated in the comments, in a layout file, specify: android:minLines=""
instead of android:lines=""
.
In Java: editText.setMinLines(int)
instead of editText.setLines(int)
.
In C# (Mono for Android) editText.SetMinLines(int)
instead of editText.SetLines(int)
.
From the Android docs:
public void setMinLines (int minlines)
Makes the TextView at least this many lines tall. Setting this value overrides any other (minimum) height setting.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With