Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set maximum characters per line for text view in android

Tags:

android

Hiii all, this may be a possible duplicate but I couldn't find solution for my problem.I need to limit the number of characters per line when displaying on the textview and display the remaining characters in the next line.I cannot set ems value and I also tried setting maxLength attribute in xml but it is not displaying the remaining characters,Can any one tell me how can I do it.

like image 257
dharan Avatar asked Jun 07 '12 14:06

dharan


People also ask

How do I limit the number of lines in a TextView?

gpetuhov/textview_limit_text. txt. This will limit number of lines to 1 and if text exceeds limit, TextView will display ... in the end of line.

How do you set the part of the text view is clickable in Android?

This example demonstrates how do I set the part of the Android textView as clickable. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml.

How do I change the text size in Android Studio?

Go to File -> Settings, a new setting dialogue box will appear. Then go to Editor -> General. Now mark the checkbox Change font size with Ctrl + Mouse wheel and click on Apply button. Now to change your editor font size, you just have to press and hold Ctrl and rotate the Mouse wheel.

What is multi line text in Android Studio?

Posted on Apr 28, 2022. Learn how to create a multiline TextView in Android application. The Android TextView widget is used to display text in your application. When you have a text that's longer than one line, then the TextView will automatically put the text in multiple lines.


2 Answers

Using

android:maxWidth="size"

Replace the "size" with the size you prefer. For example, 100dip.

like image 184
prolink007 Avatar answered Oct 21 '22 11:10

prolink007


Use this android:maxLength="10"

For more Information refer this site

like image 28
Aerrow Avatar answered Oct 21 '22 09:10

Aerrow