dimensions - Android setMaxLines with animation -
i'm using textview viewed in listview item, when item clicked need text viewed instead of first 2 lines.
what i'm doing changing maxlines value 2 (the initial value) maximum integer value.
i need done expand animation. know how expand it, need find new height such can call expand method.
update: i'm using code solve problem, returned full height smaller actual one. think it's px , dp issue:
public int getfullheight(textview tv) { context context = tv.getcontext(); textview textview = new textview(context); textview.settext(tv.gettext().tostring()); textview.settypeface(tv.gettypeface()); textview.settextsize(typedvalue.complex_unit_px, tv.gettextsize()); int widthmeasurespec = view.measurespec.makemeasurespec(tv.getlayoutparams().width, view.measurespec.exactly); int heightmeasurespec = view.measurespec.makemeasurespec(0, view.measurespec.unspecified); textview.measure(widthmeasurespec, heightmeasurespec); return textview.getmeasuredheight(); }
given tv original textview that's 2 lines. if change complex_unit_px complex_unit_dip gets larger full size, white space @ bottom.
best solution can find this: measuring text height drawn on canvas ( android ) or here: http://egoco.de/post/19077604048/calculating-the-height-of-text-in-android
what doing is, creating paint object specified width, placing text , style use in , geting boundaries.
hope helps
Comments
Post a Comment