I have a custom view with three texts & one image: * image on left * text1 in small font below image * text2 & text3 to image's right & w/ different font sizes
Below is the View.onDraw() that renders these objects & may be helpful: protected void onDraw(Canvas canvas) { super.onDraw(canvas); int text1Width=(int)(mPaint1.measureText(mText1)); int text2Width=(int)(mPaint2.measureText(mText2)); int text3Width=(int)(mPaint3.measureText(mText3)); int text1Height = (int)(-mPaint1.ascent() + mPaint1.descent()); int text2Height = (int)(-mPaint2.ascent() + mPaint2.descent()); int text3Height = (int)(-mPaint3.ascent() + mPaint3.descent()); int imgWidth = mBitmap.getWidth(); int imgHeight = mBitmap.getHeight(); //Draw bitmap on left float imgLeft = getPaddingLeft(); float imgTop = getPaddingTop(); canvas.drawBitmap(mBitmap, imgLeft, imgTop, null); //Draw text1 below bitmap int text1x = getPaddingLeft(); int text1y = getPaddingTop()+imgHeight +GAP_IMAGE_TEXT1+text1Height; canvas.drawText(mText1, text1x, text1y, mPaint1); //assert (text1Width <= imgWidth) int view23Width = getWidth()-getPaddingLeft()-imgWidth - GAP_IMAGE_TEXT2; int text23Width = text2Width + GAP_TEXT2_TEXT3 + text3Width; int gap12 = GAP_IMAGE_TEXT2; if( text23Width < view23Width) { gap12 = (int)((view23Width-text23Width)/2.0f); } //Draw text2 on right & centerY int text2x = imgWidth+gap12; canvas.drawText(mText2, text2x, getHeight()/2.0f, mPaint2); //Draw text3 to right of text2 w/ a different Paint int text3x = text2x+text2Width+GAP_TEXT2_TEXT3; canvas.drawText(mText3, text3x, getHeight()/2.0f, mPaint3); } There are limitations as the text portion is not as nearly flexible as TextView. On Jun 24, 12:55 pm, Marco Nelissen <marc...@android.com> wrote: > Just map that textview to a different column in your result set. > > On Wed, Jun 24, 2009 at 12:52 PM, Rick <rmanc...@mit.edu> wrote: > > > I am also looking to do something with an image on the left and two > > textviews arranged as below: > > > +------------------------------------ > > | +-------+ TextView1 > > | | Image | > > | +-------+ TextView2 > > +------------------------------------ > > > It appears possible to use one textview, but TextView2 needs to have > > smaller font size compared to TextView1. I am able to create it so > > that there is the image and one textview, but how could I change the > > data for the second textview? > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---