Hi,

I guess now i have understood my issue and can explain it much better and
clearly.

I am loading all my view dynamically in a Horizontal ViewGroup.  Inside one
view there a collection of pictures along with text and the bottom.  I have
the width and height of the view fixed (When creating a view i pass the
width and height to the layout params).

The image is loaded dynamically, till then a loading icon is display.  But
the text is already display in the TextView.  The visible lineCount that I
get before the image is different than the lineCount that I actually
displayed after the Image is loaded.  I want to revalidate the whole view
again after the image loading and displayed in the UI.

I tried sevaral methods to revalidate the TextView, the Layouts, but none
of it help me to get the correct visible line count after image is loaded.

-Ankur.


On Sat, Feb 15, 2014 at 5:27 PM, Ralph Bergmann | the4thFloor.eu <
[email protected]> wrote:

> Am 13.02.14 03:54, schrieb Ankur Avlani:
> > Can someone please suggest me some faster was to achieve my requirement.
>
> try this one:
>
> /**
>  * Calculates the lines needed to show the text.
>  *
>  * @param paint
>  *           the TextPaint from the TextView
>  * @param text
>  *           the text for the calculation
>  * @param textAppearance
>  *           text typeface, size, and style
>  * @param avail
>  *           the available width
>  * @return the number of lines needed to show the text
>  */
> public static int neededLines(final TextPaint paint, final String text,
> final TextAppearanceSpan textAppearance, final int avail) {
>
>    if (TextUtils.isEmpty(text)) {
>       return 0;
>    }
>
>    final TextPaint textPaint = new TextPaint();
>    textPaint.set(paint);
>
>    textPaint.setTextSize(textAppearance.getTextSize());
>    textPaint.setTypeface(Typeface.create(textAppearance.getFamily(),
> textAppearance.getTextStyle()));
>
>    final StaticLayout layout = new StaticLayout(text, textPaint, avail,
> Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
>    final int lineCount = layout.getLineCount();
>
>    return lineCount;
> }
>
>
>
> Ralph
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to