Question

Please help me to add a linear layout which contains a AdView on a canvas. How can I set the layout position parameters? I'm new to android. I'm unsure about drawing layout on Canvas. Help me! Thanks in advance

Was it helpful?

Solution

Before anything else, to my understanding, the canvas is actually an AdView - my guess is you're using AdMob. But, that's a View.

A LinearLayout is a ViewGroup and as its Javadoc description says, it's a view that contains Views - imagine it's a container of Views. You're supposed to use ViewGroups within ViewGroups only, not have them within Views. A View is supposed to draw something simple: a text, an image, a drawable or any combination of these. I would suggest to start reading the User Interface article from developers.

Going back to your question: A LinearLayout will lay the textview after the canvas. If you need to add one on top of another use either a FrameLayout or a RelativeLayout. Also, get used to use XML layout. This link should get you started.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top