Limiting a String to 2 lines in android, then cut it and concatenate a String -


my question may sound bit weird i'll try explain better here.

i ahve textview in android, @ inferior part of activity. want have limited 2 lines, reachable adding following line in textview xml element:

android:maxlines="2" 

okay, we've got limited 2 lines. then, in activity, make:

termsandconditions = (textview) findviewbyid(r.id.textview1); termsandconditions.settext(terms); 

okay, i've got big string terms , conditions, limited 2 lines due xml attribute.

now question is, how can cut after having limited 2 lines, , concatenate string "read more"? don't need in same textview or whatever, want looks like:

terms: blablablalblalbla blal blablalblalblalblalbla lalblalblalblalblalblalb lalblalblalb lalblalblalblalblalb lalblalblalb lalblalblalblalb lalb bla view more.

thanks , hope can understand problem.

you can use setellipsize (textutils.truncateat where) method of textview or android:ellipsize xml attribute.

public void setellipsize (textutils.truncateat where) added in api level 1

causes words in text longer view wide ellipsized instead of broken in middle. may want setsingleline() or sethorizontallyscrolling(boolean) constrain text single line. use null turn off ellipsizing. if setmaxlines(int) has been used set 2 or more lines, end , marquee* supported (other ellipsizing types not anything).

related xml attributes

android:ellipsize 

Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

What is the difference between data design and data model(ERD) -

ios - Can NSManagedObject conform to NSCoding -