Question

I want to position several views on the screen , AbsoluteLayout makes it. but it is deprecated . I have tried to use framelayout with setMargin() function programmaticlly. But it doesn't work!

Was it helpful?

Solution

You can use a relative layout with full height/width and set margins/alignment rules on the views.

OTHER TIPS

You should use RelativeLayout, if you dont want to use AbsoluteLayout, and use setMargin methods there to set position of views in it.

You have to use and play with the other layouts. The absolute Layout is deprecated because there are so many devices with different screens and if you use absolute coordiantes the app will just be plain ugly. If it's an app for you then go ahead and use the AbsoluteLayout, it will still work. If not, I suggest you find a tutorial and follow it, you can do anything you want with the other layouts, it's like a Lego.

You have to use a combination of different layouts. Specify padding, margins as required.

You may use TableLayout with TableRows which in turn have Relative/Linear Layouts to them. Any combination can be used, but avoid nesting too much of layouts, they may reduce the performance of your application.

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