2

I would like to create a custom View (that will be inflated from XML) which will be drawn at given x\y coordinates. I know I can create a custom View which will implement onDraw(Canvas canvas), but I want this View to be inflated from XML.

On Canvas I can only draw lines, rectangles and such.. But I want to inflate a whole XML layout..

How can I do that??

ofirbt
  • 1,846
  • 7
  • 26
  • 41

2 Answers2

2

You can use a FrameLayout as a main layout.

Inflate the layout you want.

Add it to the FrameLayout.

Then add padding / margin with LayoutParams.

Murat Nafiz
  • 1,438
  • 17
  • 28
2

I've ended up using RelativeLayout as mentioned here:

Set the absolute position of a view

Thanks for the answers!

Community
  • 1
  • 1
ofirbt
  • 1,846
  • 7
  • 26
  • 41