I’m adding a custom View to the parent layout, witch is a RelativeLayout.
I also need to move this View on the screen so I do:
myView.layout(xx, yy, width, height);
This works. The view is moved each time I call this.
The Problem is that when this view is moved,
a copy of it keeps hanging on the top left corner of the layout,
like this:
Why this happens and how can I prevent this?
Thank you
— Edit —
Some code below.
In the constructor of my custom View:
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
inflater.inflate(R.layout.ipmaps_lib_balloon_overlay, this);
I then add this View to its parent:
final RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
parentLayout.addView(myView, params);
When I need to move the View I just do:
myView.layout(startX, startY, width, height);
myView.invalidate
I found the reason for this strange behaviour.
It was my fault.
Whenever I changed the position of this message balloon,
I was as well calling
view.draw(canvas),and for this reason, the view was being drawn twice.
Thank you all very much.