public class BorderedTableLayout extends TableLayout {
private Rect mRect;
private Paint mPaint;
public BorderedTableLayout(Context context, AttributeSet attrs) {
super(context, attrs);
mRect = new Rect();
mPaint = new Paint();
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setColor(Color.BLACK);
}
@Override
protected void onDraw(Canvas canvas) {
Rect r = mRect;
Paint paint = mPaint;
getDrawingRect(r);
r.right--;
r.bottom--;
canvas.drawRect(r, paint);
super.onDraw(canvas);
}
}
On Mon, Jan 26, 2009 at 2:08 AM, MaTriXy <[email protected]> wrote:
>
> can you post the full solution??
> i need to show up a table with borders and bumped into your thread.
>
>
> On Dec 19 2008, 11:41 am, "for android" <[email protected]> wrote:
> > Thank you very much it works :)
> >
> > On Fri, Dec 19, 2008 at 2:42 PM, Romain Guy <[email protected]>
> wrote:
> >
> > > This is a classic off by 1 error with the drawRect method. There was
> > > an interesting presentation at JavaOne on this topic. Anyway, all you
> > > need to do is the following:
> >
> > > getDrawingRect(r);
> > > r.right--;
> > > r.bottom--;
> >
> > > And you're done.
> >
> > > On Fri, Dec 19, 2008 at 10:08 AM, for android <[email protected]>
> > > wrote:
> > > > Attached is a sample code of what i am trying to do.so that the prb
> is
> > > more
> > > > clear.I hope I get some help...
> >
> > > > On Fri, Dec 19, 2008 at 11:47 AM, for android <[email protected]>
> > > wrote:
> >
> > > >> any help????
> >
> > > >> On Thu, Dec 18, 2008 at 6:42 PM, for android <[email protected]>
> > > wrote:
> >
> > > >>> i need to get a customizable tablelayout with borders. Hence in the
> > > >>> onDraw,I have the following code,but i get only the left side and
> top
> > > of the
> > > >>> rectangle.but not on the right and bottom lines of the rectangle.
> >
> > > >>> I have layout in which the layout has a white background.And that
> > > layout
> > > >>> has a table with blue background.I am trying to have bordered table
> > > layout
> > > >>> for that:The layout is something like this:
> >
> > > >>> <LinearLayout bckgrnd color=white>
> > > >>> <BorderedTableLayout bckgrnd color=blue>
> > > >>> <LinearLayout>
> >
> > > >>> public BorderedTableLayout(Context context, AttributeSet attrs) {
> > > >>> super(context, attrs);
> > > >>> mRect = new Rect();
> > > >>> mPaint = new Paint();
> >
> > > >>> mPaint.setStyle(Paint.Style.STROKE);
> > > >>> mPaint.setColor(Color.BLACK);
> > > >>> }
> >
> > > >>> @Override
> > > >>> protected void onDraw(Canvas canvas) {
> > > >>> Rect r = mRect;
> > > >>> Paint paint = mPaint;
> > > >>> getDrawingRect(r);
> >
> > > >>> canvas.drawRect(r, paint);
> > > >>> super.onDraw(canvas);
> > > >>> }
> >
> > > --
> > > Romain Guy
> > > Android framework engineer
> > > [email protected]
> >
> > > Note: please don't send private questions to me, as I don't have time
> > > to provide private support. All such questions should be posted on
> > > public forums, where I and others can see and answer them
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---