What Mistake am i doing in this Popup?

Problems with Canvas, OpenGL, etc...

What Mistake am i doing in this Popup?

Postby mr_muskuraha » Fri Dec 03, 2010 2:29 pm

dear friends,

i have created a custom popup to show on mapview

here is the code

Code: Select all
public class BalloonLayout extends LinearLayout
{
   
   private Paint   panelPaint, borderPaint ;
   
   public BalloonLayout(Context context, AttributeSet attrs) {
      super(context, attrs);
      init();
   }
   
   public BalloonLayout(Context context) {
      super(context);
      init();
   }
   
   
   private void init() {
      panelPaint = new Paint();
      panelPaint.setARGB(0, 0, 0, 0); //gray
      //innerPaint.setAntiAlias(true);
      
      
      borderPaint = new Paint();
      borderPaint.setARGB(255, 255, 0, 0);
      
      borderPaint.setColor(Color.rgb(255, 106, 0));
      borderPaint.setAntiAlias(true);
      borderPaint.setStyle(Style.STROKE);
      borderPaint.setStrokeWidth(2);
      
      
      
   }
   
   
   public void setInnerPaint(Paint innerPaint) {
      this.panelPaint = innerPaint;
   }

   
   public void setBorderPaint(Paint borderPaint) {
      this.borderPaint = borderPaint;
   }
   
   
   

    @Override
   protected void dispatchDraw(Canvas canvas) {       
     
       
        RectF baloonRect = new RectF();
        baloonRect.set(0,0, getMeasuredWidth(),2*(getMeasuredHeight()/3) );
       
       
       
        panelPaint.setARGB(230, 255, 255, 255);
       
        canvas.drawRoundRect(baloonRect, 10, 10, panelPaint);
        canvas.drawRoundRect(baloonRect, 10, 10, borderPaint);
       
        Path baloonTip = new Path();
        baloonTip.moveTo(5*(getMeasuredWidth()/8), 2*(getMeasuredHeight()/3));
        baloonTip.lineTo(getMeasuredWidth()/2, getMeasuredHeight());
        baloonTip.lineTo(3*(getMeasuredWidth()/4), 2*(getMeasuredHeight()/3));
       
        canvas.drawPath(baloonTip, panelPaint);
        canvas.drawPath(baloonTip, borderPaint);
     
               
        super.dispatchDraw(canvas);
    }
   


}


please note it is showing line above triangle which looks weired
any one suggest me what mistake am i doing here or how can i remove this ugly line?
Attachments
popup.jpg
popup
popup.jpg (11.74 KiB) Viewed 302 times
mr_muskuraha
Senior Developer
Senior Developer
 
Posts: 142
Joined: Wed Jan 13, 2010 8:49 am

Top

Re: What Mistake am i doing in this Popup?

Postby blundell » Sun Dec 05, 2010 8:11 pm

Your saying to draw a rounded rectangle:
Code: Select all
canvas.drawRoundRect(baloonRect, 10, 10, borderPaint);


I can't actually see where you are drawing the white panel paint for the triangle, but if you can edit this code, just let it draw the white triangle one more pixel in height and this will overwrite the erroneous orange line.
User avatar
blundell
Master Developer
Master Developer
 
Posts: 1610
Joined: Tue Nov 18, 2008 12:58 pm
Location: UK

Top

Return to Android 2D/3D Graphics - OpenGL Problems

Who is online

Users browsing this forum: Exabot [Bot] and 2 guests