Hi all , i have a custom View with layout <LinearLayout android:id="@+id/story_image_layout" xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginLeft="5px" android:layout_marginRight="5px"> <AbsoluteLayout android:orientation="vertical" android:background="@drawable/image_back" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="5px"> <ImageView android:id="@+id/story_image" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_y="10px" android:layout_x="5px"/> <ImageView android:id="@+id/story_zoom" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/zoom_in"/> </AbsoluteLayout> <TextView android:id="@+id/story_text_partial" android:layout_width="wrap_content" android:layout_height="wrap_content" android:lineSpacingExtra="5px" android:layout_marginLeft="10px" /> </LinearLayout> And trying to calc And a long string. I want part of this string to go to the TextView on the right . To do that i'm trying to measure the imageview on the left and calculate the size of the string i need to put in my textview.
LinearLayout vParent = (LinearLayout) findViewById (R.id.story_image_layout); AbsoluteLayout vImage = (AbsoluteLayout) vParent.getChildAt(0); int shortTextWidth = vParent.getMeasuredWidth() - vImage.getMeasuredWidth(); TextView vText = (TextView) findViewById(R.id.story_text); TextView vTextShort = (TextView) vParent.getChildAt(1); int mesuredHeight = vParent.getMeasuredHeight(); int lineHeight = vTextShort.getLineHeight(); int nmbLines = mesuredHeight / lineHeight - 2; Paint mPaint = new Paint(); int breakText = mPaint.breakText(mStoryText.toCharArray(), 0, mStoryText.length(), shortTextWidth, null); mStoryBreakIdx = nmbLines * breakText; } vTextShort.setText(mStoryText.substring(0, mStoryBreakIdx)); It all works fine, except i can't set the text into the textView. If it's in constructor getMesured return 0; if it's in the onSizeChanged - measurements are calculating but TextView after set text have measurements too small to fit the text. If i put set text in a thread for example everything works, but i don't want a delay . Question - where i need set text to my view to render this correctly ? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---