Multiline EditText in Android Example


EditTexts in Android Programming extends android.widget.TextView and so are multi-lined by default.

You can make your EditTexts multi-line by added certain attributes to the EditTexts View.

EditText Multiline example Android
EditText Multiline example Android

Lets see an Example :

<EditText
   android:id="@+id/editText1"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:lines="10"
   android:minLines="5"
   android:gravity="top|left"
   android:maxLines="15" />

1. android:lines

This tag makes the EditText be exactly as many lines tall as specified as value. It accepts an integer value

2. android:minLines

This tag makes the EditText be at least x many lines tall as specified as value. It accepts an integer value

3. android:maxLines

This tag makes the EditText be at most x many lines tall as specified as value. It accepts an integer value

Note : For multiline EditText by default the cursor and hint text is displayed in the center, you can use android:gravity attribute to set it at top and left of the EditText view :

android:gravity="top|left"

Also remember to set android:layout_height:wrap_content.

Advertisements
Try Out Code2care Dev Tools:

Advertisements



#Android #Java #Linux #Microsoft #Google #Python #MacOS #Notepad++ #Microsoft Teams #CSS #PHP #SharePoint #Html #Linux #C-Program #Bootstrap #jQuery #Sublime #Android-Studio #Facebook #Eclipse #WhatsApp #News #MySQL #Json #HowTos #JavaScript #FTP #S3


Advertisements


Code2care is an initiative to publish and share varied knowledge in programming and technical areas gathered during day-to-day learnings and development activities.

Students and Software Developers can leverage this portal to find solutions to their various queries without re-inventing the wheel by referring to our easy to understand posts. Technical posts might include Learnings, Tutorials, Trouble-Shooting steps, Video Tutorials, Code Snippets, How Tos, Blogs, Articles, etc.
🎉 We are celebrating the 10th years of Code2care! Thank you for all your support! We hope we made a difference.
We strong support Gender Equality & Diversity.

We stand in solidarity with Ukraine - Make a donation to UNHCR - https://donate.unhcr.org/in/en-in/ukraine-emergency