ofirbt
ofirbt

Reputation: 1886

Draw custom View on a specific x\y coordinates

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??

Upvotes: 2

Views: 9307

Answers (2)

ofirbt
ofirbt

Reputation: 1886

I've ended up using RelativeLayout as mentioned here:

Set the absolute position of a view

Thanks for the answers!

Upvotes: 2

Murat Nafiz
Murat Nafiz

Reputation: 1438

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.

Upvotes: 2

Related Questions